Know how to plug in a UDF? This function will expand the numeric part of strings specifically for sorting. Then you can delete the column (or keep it)
Function PadNums(sInp As String, Optional iLen As Long = 1) As String
' shg 2003-1115
' Expands numbers in a string to iLen characters for sorting; e.g.,
' PadNums("13A1U3", 2) = "13A01A03"
' PadNums("1.2.3.15", 3) = "001.002.003.015"
' Numbers are not shortened below their minimal representation:
' PadNums("1.123.2.3", 2) = "01.123.02.03"
' Returns unpadded values if iLen omitted
' PadNums("01.123.02.03") = "1.123.2.3"
' All non-numeric characters are returned as-is
Dim sFmt As String
Dim i As Long
Dim iNum As Long
Dim sChr As String
Dim bNum As Boolean
sFmt = String(iLen, "0")
For i = 1 To Len(sInp)
sChr = Mid(sInp, i, 1)
If sChr Like "#" Then
bNum = True
iNum = iNum * 10 + CInt(sChr)
Else
If bNum Then
PadNums = PadNums & Format(iNum, sFmt)
iNum = 0
bNum = False
End If
PadNums = PadNums & sChr
End If
Next
If bNum Then PadNums = PadNums & Format(iNum, sFmt)
End Function
Bookmarks