Special Sorting - Non-Alphabetical - Please Help

jbillh

New Member
Joined
Dec 9, 2015
Messages
13
Hi Everyone,

I have several hundred cells that I need sorted. The problem is, if I sort them alphabetically, it is in the wrong order. Here are examples of my data:

PC1000-BKS-750lb-MS
PC1000-BKS-550lb-MS
PC1000-CG-750lb-MS
PC1000-CG-550lb-MS
PC1000-DC-750lb-MS
PC1000-DC-550lb-MS

If I sort them A-Z, that is how the list comes out. If I sort them Z-A, it is reversed. Is there a way for me to sort a long list of these and have the following result?

PC1000-BKS-750lb-MS
PC1000-CG-750lb-MS
PC1000-DC-750lb-MS
PC1000-BKS-550lb-MS
PC1000-CG-550lb-MS
PC1000-DC-550lb-MS

In this list, the data is sorted by 750's before 550's and alphabetically.

Thank you very much for your help!

Adam
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
No problem,

The easiest way to do this is to use two helper columns.
This solution assumes
a. the number always comes after the second "-"
b. the letters always come after the first "-"

I assume the cells to sort start in cell A1.

insert two columns (B & C)

in cell B1 enter the formula (this extracts the numbers element)
Code:
=TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("|",SUBSTITUTE(A1,"-","|",2))+1,LEN(A1)),"-",REPT(" ",LEN(A1))),LEN( A1)))

in cell C1 enter the formula (this extracts the letters)
Code:
=TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("|",SUBSTITUTE(A1,"-","|",1))+1,LEN(A1)),"-",REPT(" ",LEN(A1))),LEN( A1)))

copy the formulas down until your last row of data.

now go to sort and filter > select custom filter > then sort Column B on Values from Z to A
then add anther element and sort column C on values from A to Z

Job done, simply hide the columns again.

note: if you are opposed to having the columns in the middle of the table, perform the steps to fill the formula in, then cut and paste the columns across the sheet out of the way, then apply the filter on the new position of the columns.


HTH

Coops
 
Upvote 0
Thanks for your help, Coops!

One other thing I forgot to mention is that this list also has a quantity associated with each of the items. The list looks more like this:

SKU Quantity
PC1000-BKS-750lb-MS - 100
PC1000-BKS-550lb-MS - 200
PC1000-CG-750lb-MS - 0
PC1000-CG-550lb-MS - 150
PC1000-DC-750lb-MS - 250
PC1000-DC-550lb-MS - 0

It also goes on for 200+ lines. Another thing is, we generate a list like this each week (with different quantity numbers) and would like to be able to sort them quickly each time.

I don't know if this changes how you would solve the issue, but if so, I would appreciate your input.

I'll try your current solution and post here about how it works.

Thanks Much,

Adam
 
Upvote 0
just pasted the new samples straight over the old stuff in column A, works a treat and sorts itself immediately. (no need to remove the formulas or sorting)

The extra info makes no difference as it looks for the first and second hyphens to extract the info.

If your having problems let me know I will try to steer you in the right direction


Edit: with regards to copying the formula down, I don't want you to suck eggs but if you double click the bottom right corner of the cell after entering the formula, it should copy it down the sheet to the last row. https://www.youtube.com/watch?v=3L5DTFQEOP4. <--- video showing process
 
Last edited:
Upvote 0
Thanks again for your reply, I can see that is working. I did do the copy/paste formula through my whole sheet as well before your last reply.

I do have some experience with Excel, but I'm certainly not as good as you are! ;)

Thanks Again,

Adam
 
Upvote 0
Jolly good, glad you managed to get it all to work.

Coops
 
Upvote 0

Forum statistics

Threads
1,215,992
Messages
6,128,165
Members
449,428
Latest member
d4vew

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