View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Adam_needs_help Adam_needs_help is offline
external usenet poster
 
Posts: 19
Default Find an exact word in a cell with many words

can "he" be replaced with a variable?

"Don Guillett" wrote:

Sub findword()
For Each c In Range("i1:i3")
x = InStr(c, "he")
If Mid(c, x - 1, 1) = " " And Mid(c, x + 2, 1) = " " Then MsgBox c.Row
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Adam_needs_help" wrote in
message ...
I have a column that contains a sentence in each cell. I want to look for
an
exact word in each sentence in the entire column. How can I do this in a
macro?

Example:

Two cells contain:
A1: She is walking the dog
A2: It is a he

I want to find only the cells containing "he" which means I should not get
A1 back even though "he" is found within the words "she" and "the." I
can't
find any discussions exactly like this anywhere.