But in cases where we have string and numbers together
Ex.
UserLoginName
amit2568
yogesh456
neeraj12
subrimaniumnamboodripad2
yogesh1
is such case string sort wud not work because it wud sort like below
yogesh1
yogesh10
yogesh2
yogesh3
.
.
.
So when we were thinking for a efficient solution which wud sort as per
string and number.....we wud require a function which wud split string
and numeric part ....
So here it goes
'=================================================================
Private Sub SplitStringAndNum
''To Split a string and number combination
'' 'yogesh1423' ===> 'yogesh' and '1423'
Dim s As String, t As String
Dim n As Long
Dim p As Long
s = "yogesh123"
t = s
t = StrReverse(s)
n = StrReverse(CStr(Val(t)))
p = InStr(s, n)
If p > 1 Then
MsgBox Mid(s, 1, p - 1) & vbTab & Mid(s, p, Len(s))
End If
End Sub
'=================================================================
Cheers