Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text "comparison" operator for "contains" used in an "IF" Function | Excel Worksheet Functions | |||
"Find" a wildcard as a place marker and "replace" with original va | Excel Discussion (Misc queries) | |||
Using "Find" function in Excel 2000, edit data without closing Fin | Excel Discussion (Misc queries) | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) |