Varying Format Part Number Sort Issue

3

1

(Current Sort Sample:)

2-1203-4
2-1206-3
2CM-
3-1610-1
3-999
…
AR3021-A-7802
AR3021-A-7802-1
B43570-
B43570-3

I am working on an 8000+ record parts list. The challenge I am running into is that different manufactures of the parts are using many varying formats for their part numbers. “Part Number” is the field I wish to sort my entire worksheet on. (There are about 10 columns of data in this worksheet.)

My methodology for attacking this challenge was to count the number of characters to the left of any “-“ and count the total number of numeric characters in the field. (I also set “Part Numbers” that started with a non-numeric character to a count value of 99 for both count calculations so those would sort after the numeric values.) From this, I was able to sort on the values to the left of the “-“ using .the MIN of the two counts. (My “Part Numbers” are in Column B and I have a header row which means that my first “Part Number” is in cell B2.)

This method worked up to a point. My challenge is that I need to subsequently sort values after the “-“ character as is illustrated by the erroneous sort of “3-1610-1” being followed by “3-999”

One of the limitations I see is that sorting with --> Data, --> Sort only gives three columns to sort on. To sort on just the characters to the left of the “-“ is costing me those three columns. So, I am unable to repeat the whole process of counting values after the “-“ character and subsequently sorting with --> Data, --> Sort after running the primary sort.

Has the sort of many differing formats of a field such as “Part Number” been solved? Is there a macro that can be applied to this challenge? If so, I would be grateful for your input.

This data is continuously updated with new part numbers so the goal here is to be able to add those additional part numbers to the bottom of the worksheet and use a macro to correctly resort the appended list.

For the record, I am not married to my approach. After all, it didn’t solve my challenge!

DarrellBAz

Posted 2015-08-28T15:35:36.567

Reputation: 31

You can use text-to-columns to separate your part numbers, delimited by a "-", and do a custom sort. The tricky part then becomes writing a macro that maintains the full part numbers in one column and gracefully automates the text-to-columns and sorting. This sounds like a better fit for StackOverflow. – Kyle – 2015-08-28T18:07:57.110

Answers

0

Say we start with data like:

enter image description here

In B1 enter:

=TRIM(MID(SUBSTITUTE($A1,"-",REPT(" ",999)),COLUMNS($A:A)*999-998,999))

and copy both across and down:

enter image description here

Then sort by cols B,C,D,E:

enter image description here

To yield:

enter image description here

Gary's Student

Posted 2015-08-28T15:35:36.567

Reputation: 15 540

I will submit this to StackOverflow. Gary's approach didn't solve this issue as the number 100 or any number starting with a "1" would come before, say 20 or any other number starting with a first character of 2 or higher. This is one of the issues I was trying to resolve. Additionally, "3-1601-1" still sorted before "3-999." – DarrellBAz – 2015-08-29T13:32:22.507