![]() |
"FIND" function
I am trying to find out if a given cell contains the word "Employment" uising
following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. |
"FIND" function
Hi GreenInIowa,
Try: What:="*Employment*Government" --- Regards, Norman "GreenInIowa" wrote in message ... I am trying to find out if a given cell contains the word "Employment" uising following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. |
"FIND" function
It sounds like you should use InStr().
with activesheet If InStr(1, .cells(i,1).Value, "employment", vbTextCompare) 0 Then MsgBox "found it" End If end with I would check for each word, then use the results: dim PosEmpl as Long dim posGov as long with activesheet posempl = InStr(1, .cells(i,1).Value, "employment", vbTextCompare) posgov = InStr(1, .cells(i,1).Value, "government", vbTextCompare) end with if posempl 0 _ and posgov 0 then msgbox "found both" end if GreenInIowa wrote: I am trying to find out if a given cell contains the word "Employment" uising following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. -- Dave Peterson |
"FIND" function
or
What:="*Employment*Government*" (just in case.) But to the original poster, if your cell has Government first, then you may not want this approach. Norman Jones wrote: Hi GreenInIowa, Try: What:="*Employment*Government" --- Regards, Norman "GreenInIowa" wrote in message ... I am trying to find out if a given cell contains the word "Employment" uising following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. -- Dave Peterson |
"FIND" function
Hi Dave,
(just in case.) Yes, the final wildcard should have been included. Thank you! --- Regards, Norman "Dave Peterson" wrote in message ... or What:="*Employment*Government*" (just in case.) But to the original poster, if your cell has Government first, then you may not want this approach. Norman Jones wrote: Hi GreenInIowa, Try: What:="*Employment*Government" --- Regards, Norman "GreenInIowa" wrote in message ... I am trying to find out if a given cell contains the word "Employment" uising following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. -- Dave Peterson |
"FIND" function
That is a clever idea. Thanks, Norman.
"Norman Jones" wrote: Hi GreenInIowa, Try: What:="*Employment*Government" --- Regards, Norman "GreenInIowa" wrote in message ... I am trying to find out if a given cell contains the word "Employment" uising following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. |
"FIND" function
There are differences, though.
=find() is case sensitive =search() isn't And if it's not found in the cell, both =find() and =search() will return an error. InStr will return 0. But, yep. They're very similar. GreenInIowa wrote: This appears to be "FIND" function in Excel. Thanks, Dave. GreenInIowa. "Dave Peterson" wrote: It sounds like you should use InStr(). with activesheet If InStr(1, .cells(i,1).Value, "employment", vbTextCompare) 0 Then MsgBox "found it" End If end with I would check for each word, then use the results: dim PosEmpl as Long dim posGov as long with activesheet posempl = InStr(1, .cells(i,1).Value, "employment", vbTextCompare) posgov = InStr(1, .cells(i,1).Value, "government", vbTextCompare) end with if posempl 0 _ and posgov 0 then msgbox "found both" end if GreenInIowa wrote: I am trying to find out if a given cell contains the word "Employment" uising following code: Set rngia = Cells(i, 1).Find(What:="Employment", LookIn:=xlValues, Lookat:=xlPart) I would like to add another word, "Government" in the same search in addition to "Employment". I was wondering how can I add multiple words if they are not next to each other. Thanks. -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 01:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com