RE: Format-Retrieve Number as Text with Regular Expression?
This GetNumber UDF (See related link below) does exactly what I asked for, which was to extract a number string and evaluate it as a number.
...........................................
Function GetNumber(s As String)
With CreateObject("vbscript.regexp")
.Pattern = "\d+([/.]\d+)?"
If .test(s) Then
GetNumber = Evaluate(CStr(.Execute(s)(0)))
Else
GetNumber = "No number found"
End If
End With
End Function
...........................................
I have a formula which gets the LEN(GetNumber(A1)), which does not work with this function if it is a decimal like 1/3Ba2C3 reads as 0.33333333. I can use RegExpFind(A1,"[\d/.]{1,}") instead, but I think there must be a way to modify GetNumber to make a similar GetText UDF. I thought I would have a try first but so far I am stumped and it could take a while, so I will post. Thanks in advance.
Re: Format-How to Force Fraction to DECIMAL?
http://www.mrexcel.com/forum/showthread.php?t=295382
This GetNumber UDF (See related link below) does exactly what I asked for, which was to extract a number string and evaluate it as a number.
...........................................
Function GetNumber(s As String)
With CreateObject("vbscript.regexp")
.Pattern = "\d+([/.]\d+)?"
If .test(s) Then
GetNumber = Evaluate(CStr(.Execute(s)(0)))
Else
GetNumber = "No number found"
End If
End With
End Function
...........................................
I have a formula which gets the LEN(GetNumber(A1)), which does not work with this function if it is a decimal like 1/3Ba2C3 reads as 0.33333333. I can use RegExpFind(A1,"[\d/.]{1,}") instead, but I think there must be a way to modify GetNumber to make a similar GetText UDF. I thought I would have a try first but so far I am stumped and it could take a while, so I will post. Thanks in advance.
Re: Format-How to Force Fraction to DECIMAL?
http://www.mrexcel.com/forum/showthread.php?t=295382