[Excel Vba] detect a word in a string

Solved
MattDF Posted messages 76 Status Membre -  
 #YOLOSWAG -
Hello,

I have created 2 macros for one of the offices at my company. I would like to combine them into a single one to avoid manipulation errors.

The first macro is for one type of client, and the second for the other type. It is possible to determine which client is concerned by the presence of a word in a specific cell's string.

To combine the 2 macros, I would need a formula that detects the presence of this word in the cell and triggers the appropriate macro accordingly.

Let's say I have a cell named "TOTO" that contains the phrase "why doesn’t my Excel formula want to work?". I need a macro formula that can tell me if the TOTO cell contains the word "want"

(You probably guessed that this is just an example)

Thank you for your help. :)
Configuration: Windows XP Firefox 2.0.0.13

2 réponses

MattDF Posted messages 76 Status Membre 67
 
Well... after ages of searching online, I finally found it.

I'm placing the result here for anyone who might be interested.

 Sub searchword() Range("TOTO").Select If ActiveCell.Text Like "*wants*" Then MsgBox " IT WORKS!" End Sub 
41
#YOLOSWAG
 
Otherwise, you can also test with the function:
inStr(range("TOTO"),"veut"))

It seems to me that it works.
0