Extracting number from Text and ()
This custom function will get the answers you are looking for
call it with
=getval(E2,3) where E2 is the string with numbers and digits and 3 is which
numberic string you want to extract. In your example make the 2nd parameter
1 in column 1; 2nd parameter 2 in column 2; and 2nd parameter 3 in column 3
Function getval(InputString As String, Index As Integer)
MyString = InputString
charcount = 1
InputLength = Len(InputString)
For i = 1 To Index
'Remove Non-Numeric digits
Do While (charcount <= InputLength) And _
((Mid(MyString, charcount, 1) < "0") Or _
(Mid(MyString, charcount, 1) "9"))
charcount = charcount + 1
Loop
If charcount InputLength Then Exit For
'Get Non-Numeric digits
MyNumber = ""
Do While (charcount <= InputLength) And _
(Mid(MyString, charcount, 1) = "0") And _
(Mid(MyString, charcount, 1) <= "9")
MyNumber = MyNumber + Mid(MyString, charcount, 1)
charcount = charcount + 1
Loop
If charcount InputLength Then Exit For
Next i
getval = MyNumber
End Function
"Confused" wrote:
In my worksheet, I have a series of strings that contain text, numbers and ().
For example,
In cell A1, string of text L(117),D(93),O(5).
In cell A2, string of text L(6),D(117),O(20)
In cell A3, string of text GRTR1%orYM(119),O(3).
The end result for each cell would be:
Column 1 Column 2 Column 3
Column 4
Result from Cell A1 117 93 5
Result from Cell A2 6 117 20
Result from Cell A3 3
119
Can anyone help me with a formula that produces the above results?
Any help is much appreciated !!
|