Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default search a string withing a string : find / search hangs

that would be one of the slower ways to do it:

Function searchStr(searchedStr, otherStr)
On Error GoTo errorHandler
indice = Instr(1,searchedStr, otherStr,vbTextCompare)
searchStr = indice
Exit Function

errorHandler:
On Error GoTo 0
searchStr = -1
End Function

if you want it to be case sensitive like FIND ("A" < "a"), then change
vbTextCompare to vbBinaryCompare

or just call instr directly instead of reinventing the wheel.

--
Regards,
Tom Ogilvy



"itarnak" wrote in
message ...

That works great

Function searchStr(searchedStr, otherStr)
On Error GoTo errorHandler
indice = Application.WorksheetFunction.Find(searchedStr, otherStr)
searchStr = indice
Exit Function

errorHandler:
On Error GoTo 0
searchStr = -1
End Function


--
itarnak
------------------------------------------------------------------------
itarnak's Profile:

http://www.excelforum.com/member.php...o&userid=27865
View this thread: http://www.excelforum.com/showthread...hreadid=478738



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
Find specific info using search string using VBA laavista Excel Discussion (Misc queries) 5 May 20th 09 07:59 PM
Search/Match/Find ANY part of string to ANY part of Cell Value TWhizTom Excel Worksheet Functions 0 July 21st 08 08:16 PM
FIND / SEARCH text compare cell to string in 3rd cell nastech Excel Discussion (Misc queries) 0 October 29th 07 02:51 AM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
VBA function : How to search a string in another string? bibi-phoque Excel Programming 5 April 19th 05 06:24 PM


All times are GMT +1. The time now is 09:45 PM.

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

About Us

"It's about Microsoft Excel"