Hey everyone,
I have a UDF that would collect a set of 9 numeric digits.
For instance:
A1 = Hello123456789?/ok
B1 = GetNumber(A1)
UDF result:
B1 = 123456789
But now I am trying to retrieve bigger values like
A1 = 23ALPHA100050822112345678930047839750ZEBRA36
B1 = GetNumber(A1)
UDF result:
B1 = #VALUE !
Required result:
B1 = 100050822112345678930047839750[TABLE="width: 460"]
<tbody>[TR]
[TD="width: 460"]Will appreciate any help.
Thank you.[/TD]
[/TR]
</tbody>[/TABLE]
I have a UDF that would collect a set of 9 numeric digits.
For instance:
A1 = Hello123456789?/ok
B1 = GetNumber(A1)
UDF result:
B1 = 123456789
Code:
Function GetNumber(ByVal S As String) As Variant
Dim X As Long, Num As Variant
For X = 1 To Len(S)
If Mid(S, X, 1) Like "[!0-9]" Then Mid(S, X) = " "
Next
For Each Num In Split(Application.Trim(S))
If Len(Num) > 8 Then
If GetNumber > 0 Then
GetNumber = CVErr(xlErrValue)
Exit Function
Else
GetNumber = CLng(Num)
End If
End If
Next
End Function
But now I am trying to retrieve bigger values like
A1 = 23ALPHA100050822112345678930047839750ZEBRA36
B1 = GetNumber(A1)
UDF result:
B1 = #VALUE !
Required result:
B1 = 100050822112345678930047839750[TABLE="width: 460"]
<tbody>[TR]
[TD="width: 460"]Will appreciate any help.
Thank you.[/TD]
[/TR]
</tbody>[/TABLE]
Last edited: