Sorting question

  • Thread starter Thread starter Joe Schmo
  • Start date Start date
J

Joe Schmo

Anyway of sorting the following without having the 10's show up first?

1a
1b
1c
2a
2b
..
..
10a
10b
10c

Thanks,


jeff
 
The best way to accomplish your sort is to add an auxilary column (any unused
column) containing just the Numeric portion of the string. Then sort the
auxilary column as the primary sort key and then the original column as the
2nd sort. the problem then becomes how to your seperate the number portion
of the string from the rest of the number.

The spreadsheet formula VALUE doesn't work, but the VBA function VAL does
work. A very simple UDF function will seperate the number from the rest of
the string

call the UDF with the following in your new auxilarary column cell B1
=NVal(B1) where

Copy the formula down the entire auxilarary column.

Then put in a VBA window the following code

-------------------------------------------------------

Function NVal(Target As Range)
NVal = Val(Target)
End Function

--------------------------------------------------------

to enter the VBa code
1) Right click on the tab on the bottom of the worksheet (normally Sheet1)
2) On the VBA menu Insert - Module
3) On the module window copy and past the function above. Don't include the
dashed lines.

4) Then go back to worksheet and sort on the auxilary column and then the
original column.
 
Back
Top