Custom sort order

vkorla

New Member
Joined
Dec 12, 2017
Messages
25
I have a list of products that need to be sorted in a very specific manner - the final sort order should be as described in the column titled "Overall Rank".

The problem I have is that I need to first sort the products by the column titled "Date". Then, for a subset of the products (namely E, F, G, H, I, J and K), I need these to be sorted first by the "Status" column as some statuses take precedence over others, even if that results in the final list not being purely sorted by date. The order of the products that should be sorted by status is defined in the column titled "Status Rank".

The column titled "Overall Rank" is what the final sort order should be.

How can I accomplish this?

Thanks in advance!

ProductDateStatusNumber of PhotosStatus RankOverall Rank
A9/26/19 10:0032
B9/26/19 10:0051
C9/27/19 10:0043
D9/28/19 10:0034
E9/29/19L237
F9/30/19M159
G10/1/19N1610
H10/1/19O348
I10/3/19P026
J10/3/19Q115
K9/24/19R0711

<tbody>
</tbody>
 
Yes, it was not checked. It made 18 replacements, but the dates that were left aligned are still left aligned and the same error persists when running the code :(
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Yes, it was not checked. It made 18 replacements, but the dates that were left aligned are still left aligned and the same error persists when running the code :(
I don't know what file you are working with. That sample file file you provided has 26 cells in columns B:C containing an "M", not 18.

Whatever file you are working with, did you ensure that columns B:C were formatted as Date/Time (like the sample file is) before you did the Find/Replace?

I did the Find/Replace on the sample file & ran the code and the sorting was done without error (apart from that the dates are in the wrong format for my regional settings :)). Try the process on that sample file.
 
Upvote 0
This is really strange... even when I download the sample file I shared with you, when I select cells B2:C27 and do a find/replace, it only does 18 replacements (you're absolutely right in that there are 26 instances of "M"), so I have no idea what's going on... is there a way you could share your file with me if you wouldn't mind?
 
Upvote 0
I really don't have a file of mine at the moment. I just downloaded yours, did the find/replace, ran the code & closed without saving.

Try find/replace with / instead of M and see if you get 52 replacements, or 36 or some different number. Also check that 'No Format Set' appears beside both the Find & Replace boxes.
If not 52 then Undo and try on smaller ranges until you can track down which cells are finding M (or /) and which are not. That might turn something up.

Another option that would normally convert those text values into dates is to just select 1 of the columns (eg C2:C27) then do Text to Columns (Data ribbon tab) -> Delimited -> Next -> Remove any check marks from delimiters (just to be safe) -> Finish
Then do the same with column B
 
Last edited:
Upvote 0
Thanks so much for all your help Peter! The issue with the dates was that in some cells I had input them as DD/MM/YYYY and in others it was MM/DD/YYYY. Thanks again & wish you all the best!
 
Upvote 0
You're very welcome. It was an interesting exercise. Glad you resolved the issue about the dates. :)
 
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,128
Members
448,947
Latest member
test111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top