You could use a UDF that expands the numeric part:
---A--- ---B---- ------------C-------------
1 Input Output
2 SBDS737 SBDS0737 B2 and down: =PadNum(A2,4)
3 SBDS749 SBDS0749
4 SBDS794 SBDS0794
5 SBDS796 SBDS0796
6 SBDS804 SBDS0804
Then sort by the second column.
Function PadNum(sInp As String, Optional ByVal iLen As Long = 1) As String
' shg 2003-1115
' Expands numbers in a string to iLen characters for sorting; e.g.,
' PadNum("13A1U3", 2) = "13A01A03"
' PadNum("1.2.3.15", 3) = "001.002.003.015"
' Numbers are not shortened below their minimal representation:
' PadNum("1.123.2.3", 2) = "01.123.02.03"
' Returns unpadded values if iLen omitted
' PadNum("01.123.02.03") = "1.123.2.3"
' All non-numeric characters are returned as-is
Dim sFmt As String
Dim iChr As Long
Dim sNum As String
Dim sChr As String
Dim bNum As Boolean
sFmt = String(IIf(iLen < 1, 1, IIf(iLen > 15, 15, iLen)), "0")
For iChr = 1 To Len(sInp) + 1 ' the +1 flushes a trailing number
sChr = Mid(sInp, iChr, 1)
If sChr Like "#" Then
bNum = True
sNum = sNum & sChr
Else
If bNum Then
bNum = False
PadNum = PadNum & Format(CDbl(sNum), sFmt)
sNum = vbNullString
End If
PadNum = PadNum & sChr
End If
Next iChr
End Function
Bookmarks