Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default when a Find statement is successful


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


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default when a Find statement is successful

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

if not rngfoundcell is nothing then
would work, too.



captbluefin wrote:

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

------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default when a Find statement is successful

Cap'n,

I don't know about a "good" way, but you can test for:

If Not rngFoundCell is Nothing Then
....

Remember, the result is a Range object, so you can also
refer to any of the normal properties:

debug.print rngFoundCell.value
debug.print rngFoundCell.Address

Incidentally, what have turkeys got to do with anything?

Cheers, Pete.



-----Original Message-----

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


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default when a Find statement is successful


thanks Dave - works like a charm

B

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default when a Find statement is successful


thanks Dave - works like a charm

BB


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

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
Find and IF statement Atif New Users to Excel 6 November 4th 09 04:40 PM
Row # of successful vlookup Chuck M Excel Worksheet Functions 3 August 19th 08 09:29 PM
Formula apparently successful but #VALUE displayed Matthew Leingang Excel Worksheet Functions 2 January 22nd 08 03:32 PM
Calculating time between successful data transmissions Donnie Excel Discussion (Misc queries) 2 December 10th 04 12:45 PM
Add to finally successful dialog box Bruce Roberson Excel Programming 10 July 29th 03 11:58 PM


All times are GMT +1. The time now is 05:30 AM.

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

About Us

"It's about Microsoft Excel"