PDA

View Full Version : [SOLVED] How to get Last Digit from Text



hardeep
12-28-2016, 03:27 AM
Hello Experts

I have below data, now i need Last Digit from the Text,the problem is its not always 1 or 2 or 3 Digit, sometime its 1 , sometimes its 25 and might be 398 or 11259

Second problem ,before every digit sometime it have Spaces and sometime not (See the Attached)



Text
Expected Result


10006-R K Mahajan Entprs,100 MON 11172 S.inv 285
285



Actually they are Invoice No. and this data it's only the unique number, which i can map with my data


Can you please help me on this

mana
12-28-2016, 04:53 AM
Function getINV(txt As String) As Long

With CreateObject("VBScript.RegExp")
.Pattern = "[0-9]*$"
getINV = .Execute(txt)(0)
End With

End Function

hardeep
12-28-2016, 06:01 AM
m Getting Error

#NAME?

=Getinv(A2)

hardeep
12-28-2016, 06:11 AM
Sorry Mana

Its my fault, it work thanks a lot