Excel 2003 VB Macro for finding txt strings

Registration date
Tuesday May 5, 2009
Last seen
May 6, 2009
 psk -
Hello, I am trying to write an Excel 2003 Visual Basic Macro that searches a cell for a particular word. But the cell contains several words. So I can't just use a cell value match formula. Any suggestions would be greatly appreciated!

2 replies


Have you tried using the SEARCH function? This function returns the index of the first occurence of the word within a string. To get the logical value (True or False) instead of the index, you can compare the return value of SEARCH function to be greater than zero.


Happy coding!
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month

Apologies, missed the fact that you need the *VBA* function for the macro and *not* the excel function for the formulas. You can use INSTR function in the VBA macro to achieve the same.

In addition, any Excel formula can be evaluated by passing the formula as string as a parameter to EVALUATE function in VBA. Hence, using EVALUATE, you can evaluate SEARCH function in the VBA macro too.

- psk