View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default searching through a string?

Function ExtractString(s As String)
Dim s1 As String, ipos As Long
Dim jpos As Long
ipos = InStr(1, s, "_", vbTextCompare)
jpos = InStr(1, s, "for", vbTextCompare)
s1 = Mid(s, ipos + 1, jpos - ipos - 2)
ExtractString = s1
End Function

Demo'd from the immediate window:
? ExtractString("c:\test\1_South East London for May-06.xls")
South East London
? extractString("c:\1_london for may-06.xls")
london

--
Regards,
Tom Ogilvy


"funkymonkUK" wrote:


how would this work if i have say the following file?

c:\test\1_South East London for May-06.xls

would this just extract "South"?

I need to extract where it came from and then mark off that the
source's file has been received.


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=538371