Tuesday 27 August 2013

Extract number from alphanumeric string in excel

PRESS ALT+F11
CLICK INSERT
MODULE
THEN PASTE THIS CODE



Function GetNumber(s As String)
    Dim j As Long
    While Not IsNumeric(Left(s, 1))
        If Len(s) <= 1 Then
            Exit Function
        Else
            s = Mid(s, 2)
        End If
    Wend
    GetNumber = Val(s)
End Function

No comments:

Post a Comment