Select Page

Extract Number in String

Vba function val() have property that help you to extract number from string. Here is code and exampe:

 

Function ExtractAmount(data As String) As Variant
    Dim s As String
    s = Split(data, "$")(1) 'part after first dollar sign
    s = Replace(s, ",", "") 'throw away any commas
    ExtractAmount = CCur(Val(s))
End Function
extract number from string in excel vba