VBA to Sort Data Alphanumerically

mfast

New Member
Joined
May 29, 2015
Messages
19
I have many different lines of part numbers that have similar data to the example below that I would want a VBA to sort alphanumerically. I just cant figure it out. Help will be much appreciated.

Excel Sort:

32583
274842
274843
274844
274845
274846
274847
641288A
641316A
641317A
641318A
641319A
641320A
641321A
641322A
641333A
641345A
641346A
641347A
641348A
641359A
641660A
641663A
641664A
641665A
641666A
641667A
641668A
641669A
641671A
641672A
641712A
64315A
64469A
64562A
CP1403
CP1404
CP1405
CP818
CP819
CP830
CP831

What I am looking for:

CP818
CP819
CP830
CP831
CP1403
CP1404
CP1405
32583
274842
274843
274844
274845
274846
274847
64315A
64469A
64562A
641288A
641316A
641317A
641318A
641319A
641320A
641321A
641322A
641333A
641345A
641346A
641347A
641348A
641359A
641660A
641663A
641664A
641665A
641666A
641667A
641668A
641669A
641671A
641672A
641712A
 

SpillerBD

Well-known Member
Joined
Jul 2, 2014
Messages
2,710
Your desired sort has some conditional ordering. It looks at the number part as a number rather than text. Your desired result has "32583" before "274842" which makes sense when sorted as a value, but not with any alphanumeric sort.
There is the same conflict in all the "CP...." items.
So you need to verify that very non-standard sort method is really what you want. Because the next person to sort (especially without what ever solution you find) probably won't be available to them. Then their list won't be in the same order....
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Watch MrExcel Video

Forum statistics

Threads
1,132,686
Messages
5,654,749
Members
418,149
Latest member
amamiche67

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
Top