Excel 2013 sorting with mixed data and different formats

时间:2016-08-31 17:21:40

标签: excel sorting

I have been doing extensive research into how to sort mixed data with excel and I have not found a solution. Below is a shortened list that is similar to what I want sorted.

2B
4C
A-2
6A-1
NA3
NA5
7F
10A
6A
HC-V
9J

I want the data to be sorted in first, numerical and then alphabetical. As below:

2B 
4C
6A
6A-1
7F
9J
10A
A-2
HC-V
NA3
NA5

Excel can do it if the numerical values do not exceed 9. Once that 10 is put in there it places the 10 at the beginning of the list as if it is the lowest number (and I know that it does not know any better since that is how it is programmed). I have looked into using helper columns but have not been able to figure out how to separate the numbers from the letters to make it work since there is no standard format for my data. Does anyone have any suggestion how to get the 10 between the data points that start with "9" and "A"?

Thanks!

1 个答案:

答案 0 :(得分:0)

The problem is that Excel sorts text character by character so since the first character of 10A is 1 Excel will put it in front of 2B.

To fix this you will need to parse the parts and either make the numbers in front 2 digit numbers so 2B is 02B or separate each part into its own cell then sort on each column in order.

To do the first

In a empty column put the following formula in the first cell:

=IF(AND(ISNUMBER(--LEFT(A1,1)),NOT(ISNUMBER(--LEFT(A1,2)))),TEXT(--LEFT(A1,1),"00") & MID(A1,2,999),A1)

and copy/fill down.

enter image description here

No you can sort on the new column:

enter image description here

You can always hide the column if you do want to see it.