Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB find (true false)

0 views
Skip to first unread message

Wildman

unread,
May 4, 2005, 9:27:56 PM5/4/05
to
I'm trying to mix in some VB in a macro I made that
looks for a particular word in a cell. If the word
exist, continue the macro. If it does not end the Macro.
any Ideas?

Cells to search for word a2:a30000
word can be mixed in with other characters.

Thanks in advance
Wildman


Bob Phillips

unread,
May 5, 2005, 5:31:51 AM5/5/05
to

For Each cell In Range(A2:A30000")
iPos = Instr(1,cell.Value,"the_word")
If iPos > 0 Then
'continue code
End If
Next cell

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Wildman" <m...@lab.com> wrote in message
news:j3si719vi62hoav6k...@4ax.com...

Harlan Grove

unread,
May 5, 2005, 1:40:08 PM5/5/05
to
Bob Phillips wrote...

>For Each cell In Range(A2:A30000")
> iPos = Instr(1,cell.Value,"the_word")
> If iPos > 0 Then
> 'continue code
> End If
>Next cell

Alternatively, could use Like.

For Each c In SomeRange
If c.Value Like "*" & your_word_here & "*" Then
'continue
End If
Next c

Sometimes exact text matching (InStr) is more useful, other times
pattern matching (Like) is.

Bob Phillips

unread,
May 5, 2005, 4:03:00 PM5/5/05
to
Yep, I agree, that is better

"Harlan Grove" <hrl...@aol.com> wrote in message
news:1115314808.2...@f14g2000cwb.googlegroups.com...

Wildman

unread,
May 5, 2005, 9:50:10 PM5/5/05
to
so what your saying is....
give my column a range name="test"

and say I'm searching for the word "Wildman"
then in my macro add...

If test.Value like "*"&"wildman"&"*" then
else
exit sub
End If

Thanks again
Wildman

Bob Phillips

unread,
May 6, 2005, 6:28:41 AM5/6/05
to
even simpler

test.Value like "*wildman*"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Wildman" <m...@lab.com> wrote in message

news:8bil71hu241deikfm...@4ax.com...

0 new messages