Originally Posted by
Excel Fox
You should change your function's declared data type to Variant as I show in red above in order to stop the error that is generated when an argument containing no digits is passed into the function.
From my standpoint, I do not think using the heavy "machinery" of the Regular Expression engine is necessary for such a simple requested functionality; here is a Function using standard built-in VBA functions that will do the same thing (note I changed the function's name to something easier to type)...
Code:
Function GetDigits(strAlNum As String) As Variant
Dim X As Long
For X = 1 To Len(strAlNum)
If Mid(strAlNum, X, 1) Like "#" Then GetDigits = GetDigits & Mid(strAlNum, X, 1)
Next
End Function
Bookmarks