Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default "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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default "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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default "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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default "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.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
"Find" a wildcard as a place marker and "replace" with original va Eric Excel Discussion (Misc queries) 1 January 27th 09 06:00 PM
Using "Find" function in Excel 2000, edit data without closing Fin rkgpihw Excel Discussion (Misc queries) 1 August 21st 06 07:39 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"