Re: Isolate Numerical Data in Cell
- From: "Bill Renaud" <Bill.No.Spam.Renaud@xxxxxxxxxxx>
- Date: Sun, 26 Aug 2007 17:04:43 -0500
This can be done with formulas, but I think formulas are actually more
cumbersome, and difficult to troubleshoot in this type of situation.
Since this is a programming newsgroup, you might be interested in my VBA
solution, which I tend to resort to:
Public Function GetString(SearchText As String, _
StartText As String, _
EndText As String) As String
Dim lngPos As Long
Dim lngStart As Long
Dim lngEnd As Long
On Error Resume Next
lngPos = InStr(1, SearchText, StartText, vbTextCompare)
If lngPos > 0 _
Then
lngStart = lngPos + Len(StartText)
lngEnd = InStr(lngStart, SearchText, EndText, vbTextCompare)
If lngEnd > 0 _
Then
GetString = Mid$(SearchText, lngStart, (lngEnd - lngStart))
Else
GetString = Mid$(SearchText, lngStart, (Len(SearchText) -
lngStart + 1))
End If
Else
GetString = ""
End If
End Function
Then, on your worksheet use the following formulas:
For the web query from MaqQuest example:
=VALUE(TRIM(GetString(A2,"Distance:","miles")))
For the names of NJ schools example:
=TRIM(GetString(A3,"»","("))
You could also include the space in the "StartText" and "EndText"
arguments to the GetString function and then eliminate the TRIM
worksheet function in the result, if you wanted.
(Note: To get the "»" character in the VBA editor, type Alt+0187. Use
the "Character Map" applet to find these.)
--
Regards,
Bill Renaud
.
- References:
- Isolate Numerical Data in Cell
- From: jtreble@xxxxxxxxx
- Isolate Numerical Data in Cell
- Prev by Date: Re: a defined name not working in Excel 2007
- Next by Date: Re: Isolate Numerical Data in Cell
- Previous by thread: Re: Isolate Numerical Data in Cell
- Next by thread: Re: Isolate Numerical Data in Cell
- Index(es):
Relevant Pages
|