Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofilter not grabbing last row Elaine Excel Worksheet Functions 2 November 28th 09 02:03 AM
Keeps grabbing more than one cell/column confused Excel Worksheet Functions 1 March 11th 09 03:42 PM
Grabbing data between worksheets andrew Excel Discussion (Misc queries) 4 July 7th 08 05:39 AM
grabbing data from another website [email protected] Excel Discussion (Misc queries) 1 July 4th 08 08:26 PM
Grabbing the Last name MABeatty Excel Discussion (Misc queries) 6 June 23rd 06 07:03 PM


All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"