Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLS CLS is offline
external usenet poster
 
Posts: 5
Default Search for a string sequence in a cell

Hi All,

Is there a way to search a cell for a chunk of text? with VBA
ex
look for here in "Hi There" since it is there highlight that cell.

I can only seem to get exact matches

Thanks
Chad


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Search for a string sequence in a cell

Hi Chad,

Not sure the entire context of what you are dealing with, but you can use
the InStr function to do this. Syntax is as follows ...

Instr(1, LookAt, LookFor)

It will return a whole number (starting position) of matched text. If no
match is found, a 0 value is returned. You can test for a cell value like
this ....

If InStr(1, Range("A1"), "Hello") 0 Then Msgbox "Was found in A1."

--
Regards,
Zack Barresse, aka firefytr

"CLS" remove NOT wrote in message
...
Hi All,

Is there a way to search a cell for a chunk of text? with VBA
ex
look for here in "Hi There" since it is there highlight that cell.

I can only seem to get exact matches

Thanks
Chad




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Search for a string sequence in a cell

Record a Macro doing a "Find" (Edit - Find or Ctrl + F). Look at the results
and make any modifications you may need... If something still is not working
post a reply back with the code and we can look at it for you...

HTH

"CLS" wrote:

Hi All,

Is there a way to search a cell for a chunk of text? with VBA
ex
look for here in "Hi There" since it is there highlight that cell.

I can only seem to get exact matches

Thanks
Chad



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Search for a string sequence in a cell

Another method that works well is using AutoFilter for your group and then
processing with SpecialCells. Very quick, very easy - once you get the hang
of it.

And I agree with Jim, the Find method is very, very fast.

You would get more results and a better solution if you posted your entire
quandry.

--
Regards,
Zack Barresse, aka firefytr

"CLS" remove NOT wrote in message
...
Hi All,

Is there a way to search a cell for a chunk of text? with VBA
ex
look for here in "Hi There" since it is there highlight that cell.

I can only seem to get exact matches

Thanks
Chad




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
Create a cell that will search multiple sheets for entered string. accesseng Excel Discussion (Misc queries) 0 January 13th 09 02:22 AM
Search a string in a cell for a list of 3 letter codes SteveT Excel Worksheet Functions 3 November 7th 08 03:11 AM
Search for string of characters in a cell BRB Excel Discussion (Misc queries) 3 August 21st 08 07:44 PM
FIND / SEARCH text compare cell to string in 3rd cell nastech Excel Discussion (Misc queries) 0 October 29th 07 02:51 AM
Using Vlookup in a string search of a cell Ralph Heidecke Excel Worksheet Functions 1 April 26th 06 06:46 PM


All times are GMT +1. The time now is 07:16 PM.

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"