![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com