Here is a function derived from a Dev Ashish post. It will take in a string and return only the numeric characters.
Code:
'---------------------------------------------------------------------------------------
' Procedure : fExtractStrNums
' Author : user
' Date : 2/27/2009
' Purpose : To extract only numerics from a string of mixed alpha,
'numerics and special chars.
'---------------------------------------------------------------------------------------
'
Function fExtractStrNums(ByVal strInString As String) As String
' From Dev Ashish
'(Q) How do I extract only characters from a string which has both numeric and alphanumeric characters?
'(A) Use the following function. Note that the If loop can be modified to extract either both Lower and Upper case character or either
'Lower or Upper case characters.
'************ Code Start **********
Dim lngLen As Long, strOut As String
Dim i As Long, strTmp As String
On Error GoTo fExtractStrNums_Error
lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
strTmp = Left$(strInString, 1)
strInString = Right$(strInString, lngLen - i)
'ADJUSTED CODE TO GET ONLY NUMERICS
If (Asc(strTmp) >= 48 And Asc(strTmp) <= 57) Then
strOut = strOut & strTmp
End If
Next i
fExtractStrNums = strOut
On Error GoTo 0
Exit Function
fExtractStrNums_Error:
MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure fExtractStrNums of Module Module1"
End Function
Good luck