Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grabbing a String between two delimiters
For some reason I can't seem to figure this one out. I
need to be able to determine a string that lies between two delimeters. Example: xyz\abc\defgh I need to be able to grab out the "abc" portion without knowing the exact size of what the string will be between the two delimters (\). In looking at a book I have there was mention of a function called dhExtractString but it appears not to work on Excell 2002 (SP2) unless there is a reference that I need to add. Any help would be appreciated. Thanks. Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grabbing a String between two delimiters
Kirk,
Use the Split function. E.g., Dim S As String Dim Arr As Variant S = "xyz\abc\defgh" Arr = Split(S, "\") MsgBox Arr(1) -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Kirk" wrote in message ... For some reason I can't seem to figure this one out. I need to be able to determine a string that lies between two delimeters. Example: xyz\abc\defgh I need to be able to grab out the "abc" portion without knowing the exact size of what the string will be between the two delimters (\). In looking at a book I have there was mention of a function called dhExtractString but it appears not to work on Excell 2002 (SP2) unless there is a reference that I need to add. Any help would be appreciated. Thanks. Kirk |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grabbing a String between two delimiters
Try using the following function...
Debug.Print strReturnValue("xyz/abc/defgh","/","/") Public Function strReturnValue(strMessageBody As String, strTag1 As String, strTag2 As String) As String Dim StartPos As Long Dim EndPos As Long StartPos = InStr(1, strMessageBody, strTag1, vbTextCompare) + Len(strTag1) EndPos = InStr(StartPos, strMessageBody, strTag2, vbTextCompare) If EndPos = 0 Then EndPos = StartPos strReturnValue = Mid(strMessageBody, StartPos, EndPos - StartPos) End Function "Kirk" wrote in message ... For some reason I can't seem to figure this one out. I need to be able to determine a string that lies between two delimeters. Example: xyz\abc\defgh I need to be able to grab out the "abc" portion without knowing the exact size of what the string will be between the two delimters (\). In looking at a book I have there was mention of a function called dhExtractString but it appears not to work on Excell 2002 (SP2) unless there is a reference that I need to add. Any help would be appreciated. Thanks. Kirk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Autofilter not grabbing last row | Excel Worksheet Functions | |||
Keeps grabbing more than one cell/column | Excel Worksheet Functions | |||
Grabbing data between worksheets | Excel Discussion (Misc queries) | |||
grabbing data from another website | Excel Discussion (Misc queries) | |||
Grabbing the Last name | Excel Discussion (Misc queries) |