when a Find statement is successful

C

captbluefin

Hello and Happy turkey day to all.
This question falls in the "I know there has to be a better way."
category.

An example will tell all:

Here is the Find statement
dim rngFoundCell as Range
set rngFoundcell = (cells.find:= "TEST")

Now the question:

When the find is not succesful I can use the following statement:

If rngFoundCell is Nothing then
MsgBox "The word TEST has not been found."
End If

When the find statement is successful I want to be able to use an if
statement to say something like

If rngFoundcell is ???? then
MsgBox " The word TEST has been found."
End If

What I have been doing is using the following statement:

If rngFoundcell is nothing then
Else
MsgBox "The word TEST has been found."
End IF

The above statement accomplishes what I am trying to do, however, I
know there must be a better way to phrase the statement

I have tried:
If not rngFoundCell then

The statement does not work.

I have also tried the following statement in many permutations to no
avail:

If rngFoundcell.text = "TEST" then

What is the "good" way to test for a succesful Find statement??

Thanks
 
D

Dave Peterson

I like your if/then/else structure, but:

if not rngfoundcell is nothing then
would work, too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top