View Single Post
  #1   Report Post  
Nate Oliver
 
Posts: n/a
Default Function in XL or in VBA for XL that pulls numeric digits from a t

Hello,

Does XL and/or VBA for XL and/or anyone have any similar function that would
work in XL? If so, I would like to have knowledge of it.


While this thread is somewhat dated, another potential approach is to use a
byte array. E.g.,

Function retNumeric(ByVal myStr As String) As Double
Dim b() As Byte, i As Long, myNum As String
b = StrConv(myStr, vbFromUnicode)
For i = LBound(b) To UBound(b)
Select Case b(i)
Case 46, 48 To 57
myNum = myNum & ChrW$(b(i))
End Select
Next
retNumeric = myNum
End Function

Sub tester()
MsgBox retNumeric("A123B456C789")
End Sub

You can change the ASCII chars and function data type to adjust the parsed
return.

Regards,
Nate Oliver