• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sort Row by Column or Other Solution

alielle3

New Member
I have a very specific issue and I'm trying to work it out to little success. I have 2 sheets in my file and I need to be able to sort rows on one based on the column in the other.

Example:


Sheet 1:

Date - Invoice# - Amount

Date - Invoice# - Amount

Date - Invoice# - Amount

Date - Invoice# - Amount

Date - Invoice# - Amount


Sheet 2:

Invoice# - Invoice# - Invoice#

Merch ---- Merch ---- Merch

Freight -- Freight -- Freight


So sheet 1 is able to be sorted by invoice simply enough with the built-in Sort Ascending. And sheet 2 was simple enough by clicking data -> sort -> Row 1 (options -> left to right). However, the invoice numbers have recently turned over and gone back from 999999 to 000001 so that sorting option is now out. Sheet 1 can still be sorted, now by date instead but there is no such option for sheet 2.


My theory is I can use the order of the invoices on sheet 1 after sorting by date to determine the sort order on sheet 2. That, or somehow convince Excel that 000001 > 999999 when sorting.


I'm OK with macros and VBA but I'm not sure where to start here. Any help would be greatly appreciated!
 
Hi, alielle3!


First of all welcome to Chandoo's website Excel forums. Thank you for your joining us and glad to have you here.


As a starting point I'd recommend you to read the green sticky topics at this forums main page. There you'll find general guidelines about how this site and community operates (introducing yourself, posting files, netiquette rules, and so on).


Among them you're prompted to perform searches within this site before posting, because maybe your question had been answered yet.


Feel free to play with different keywords so as to be led thru a wide variety of articles and posts, and if you don't find anything that solves your problem or guides you towards a solution, you'll always be welcome back here. Tell us what you've done, consider uploading a sample file as recommended, and somebody surely will read your post and help you.


And about your question...


If you haven't performed yet the search herein, try going to the topmost right zone of this page (Custom Search), type the keywords used in Tags field when creating the topic or other proper words and press Search button. You'd retrieve many links from this website, like the following one(s) -if any posted below-, maybe you find useful information and even the solution. If not please advise so as people who read it could get back to you as soon as possible.


In this case, could you use a helper row with a zero for the old invoice numeration and a 1 for the new? If so you'd be able to normally sort as previously.


Regards!
 
I apologize for just jumping in to the issue. I did search so I suppose I should have said that upfront as not to appear lazy.


I'm not positive I understand what you mean by helper row. If I set it so that it adds a 1 if the invoice is under a certain number and then add that as a secondary sort requirement, that could work. However, it requires a tad more work for the user and they get miffy with me for any additional step they must take.


I was thinking about having sheet 2 add 1000000 to any cell with an invoice <= 999999, and then having it only display the first 6 digits but I'm still debating that.
 
Hello alielle3,

Going with SirJB7's suggestion of using a helper row, you could create a helper row on Sheet2 as follows:


in Sheet2,

Assuming that your invoice numbers are on Row#2

On Row #1, put the following formula in cell A1, and copy to additional cols

=MATCH(A2,Sheet1!$B:$B,0)


in this case, I am assuming that you have the invoice #s in column B on Sheet1.


Then sort on Sheet2's Row #1. You will have the invoice #s in the same order you have the invoice #s on Sheet1.


Cheers,

Sajan.
 
Back
Top