Function StripChar(aText As String)
Dim I As Integer
StripChar = ""
For I = 1 To Len(aText)
aChar = Mid(aText, I, 1)
Select Case aChar
Case "0" To "9"
StripChar = StripChar & aChar
End Select
Next
End Function
Sub macroName()
Dim txt As String
txt = "How is 123 a number?"
finalnumber = Int(StripChar(txt))
End Sub
Function DigitsOnly(ByVal s As Variant) As Variant 'by Rick Rothstein
Dim i As Long
For i = 1 To Len(s)
If Mid(s, i, 1) Like "[!0-9]" Then Mid(s, i, 1) = Chr(1)
Next i
DigitsOnly = Replace(s, Chr(1), "")
End Function
Val("63H") returns 63
Val("xy123") returns 0
Val("12.6AB") returns 12.6
Keep in mind that Val will only work if your string always starts with a number and then text follows it.
Actually, VAL will work if the string starts with a non-numeral. It will return 0, but it won't throw an error like CDbl and other VBA conversion functions.