Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Not understanding If Not..Then nothing

I'm confused by using an "If not then nothing". It seems to me that if
I do a find, and the text I searched for is found, then the value of
the range it is found in would NOT be nothing. But it is. So is that
correct, that when XL finds what it's looking for, the value of that
range is "nothing"? I won't be surprised much if it's the opposite of
what makes sense to me. Everything else in VBA is!
Thanks for your help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Not understanding If Not..Then nothing

I did a more testing. It's always nothing! If it finds the text, the
range variable is nothing. If it doesn't find the text, the range
variable is nothing.
That begs the question: If you do a "Find" in a macro, how do you know
if a cell with that value was found? I copied a "If Not rangevariable
is Nothing" from another thread which I thought would tell me if the
value had been found. I guess it does something else. So, after you do
a find, how do you know if it was found or not?
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Not understanding If Not..Then nothing

davegb,

Your question seems a bit confusing. I use the find method quite
frequently, and xl does not return an empty (Nothing) variable when the value
is actually found, (Maybe xl is not actually finding it in your tests.)
Ben

--
When you lose your mind, you free your life.


"davegb" wrote:

I did a more testing. It's always nothing! If it finds the text, the
range variable is nothing. If it doesn't find the text, the range
variable is nothing.
That begs the question: If you do a "Find" in a macro, how do you know
if a cell with that value was found? I copied a "If Not rangevariable
is Nothing" from another thread which I thought would tell me if the
value had been found. I guess it does something else. So, after you do
a find, how do you know if it was found or not?
Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Not understanding If Not..Then nothing

Ben, Thanks for your reply.
Yes, XL is finding it. It's just still saying that FoundCell is
nothing.
Dave

ben (remove this if mailing direct) wrote:
davegb,

Your question seems a bit confusing. I use the find method quite
frequently, and xl does not return an empty (Nothing) variable when the value
is actually found, (Maybe xl is not actually finding it in your tests.)
Ben

--
When you lose your mind, you free your life.


"davegb" wrote:

I did a more testing. It's always nothing! If it finds the text, the
range variable is nothing. If it doesn't find the text, the range
variable is nothing.
That begs the question: If you do a "Find" in a macro, how do you know
if a cell with that value was found? I copied a "If Not rangevariable
is Nothing" from another thread which I thought would tell me if the
value had been found. I guess it does something else. So, after you do
a find, how do you know if it was found or not?
Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Not understanding If Not..Then nothing

Here's my code:

'Test for Client Disab
On Error Resume Next
RecSht.Range("1:1").Select
FoundCell = Cells.find(What:="Client Disab", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
_
MatchCase:=False)

If Not FoundCell Is Nothing Then
RecSht.Range("aa4").Copy Destination:=CtyExtr.Range("N5")

I've done a watch on "FoundCell", dimmed as range,on datasheets with
and without the searched for text ("Client Disab"). Whether the text is
found or not, FoundCell is nothing.
Any suggestions?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Not understanding If Not..Then nothing

You're missing a Set command.

FoundCell = Cells.find(What:="Client Disab",
After:=ActiveCell,
should be
Set FoundCell = Cells.find(What:="Client Disab",
After:=ActiveCell,



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"davegb" wrote in message
oups.com...
Here's my code:

'Test for Client Disab
On Error Resume Next
RecSht.Range("1:1").Select
FoundCell = Cells.find(What:="Client Disab",
After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext,
_
MatchCase:=False)

If Not FoundCell Is Nothing Then
RecSht.Range("aa4").Copy
Destination:=CtyExtr.Range("N5")

I've done a watch on "FoundCell", dimmed as range,on datasheets
with
and without the searched for text ("Client Disab"). Whether the
text is
found or not, FoundCell is nothing.
Any suggestions?



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
Understanding .End(xlUp) (1,1) Dennis Excel Discussion (Misc queries) 4 April 4th 23 02:13 PM
Understanding formula Dig Excel Worksheet Functions 1 July 3rd 08 03:31 PM
Understanding SUMPRODUCT() Jakobshavn Isbrae Excel Worksheet Functions 18 February 4th 08 08:41 AM
Not understanding MROUND [email protected] Excel Worksheet Functions 1 July 31st 07 03:40 PM
Understanding Templates Syed Zeeshan Haider Excel Programming 6 May 25th 05 12:39 AM


All times are GMT +1. The time now is 06:53 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"