Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default Logical tests

Hello,

There may be more but when applying logical tests to a cell to check if it
is empty there are 3 common ones that seem to be used...

Range("A1").text
Range("A1").value
Isempty(Range("A1")

When would each be used?

D


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Logical tests

The first two returns the text or value, where text is the string and value
is a variant. How you then use this value depends on what you intend to do
with it. The last is a logical test for a variable as to whether it has
been initialized. Therefore all three at not the same.

To be strictly applied then IsEmpty should read

IsEmpty(Range("A1").Value); is effectively doing the first by returning the
value from the cell A1 then applying a logical test to determine if it has
been initialized; if the cell has a value (not Null) then it returns true.
So If Range("A1").Value = "" then and IsEmpty(Range("A1").Value) are
equivalent in this case.

Note: That using IsEmpty only returns meaningful results for variants,
Range("A1").Text does not return a variant but text.



--

Regards,
Nigel




"Dave" wrote in message
...
Hello,

There may be more but when applying logical tests to a cell to check if it
is empty there are 3 common ones that seem to be used...

Range("A1").text
Range("A1").value
Isempty(Range("A1")

When would each be used?

D



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Logical tests

Note that .Value returns the underlying value in a cell, .Text returns what
you see. For instance, if a cell has a date, .Value returns the number of
days since 1st Jan 1900, which is how Excel stores dates, whereas .Text will
return the date as formatted, such as 01/02/2008.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Nigel" wrote in message
...
The first two returns the text or value, where text is the string and
value is a variant. How you then use this value depends on what you
intend to do with it. The last is a logical test for a variable as to
whether it has been initialized. Therefore all three at not the same.

To be strictly applied then IsEmpty should read

IsEmpty(Range("A1").Value); is effectively doing the first by returning
the value from the cell A1 then applying a logical test to determine if it
has been initialized; if the cell has a value (not Null) then it returns
true. So If Range("A1").Value = "" then and IsEmpty(Range("A1").Value)
are equivalent in this case.

Note: That using IsEmpty only returns meaningful results for variants,
Range("A1").Text does not return a variant but text.



--

Regards,
Nigel




"Dave" wrote in message
...
Hello,

There may be more but when applying logical tests to a cell to check if
it
is empty there are 3 common ones that seem to be used...

Range("A1").text
Range("A1").value
Isempty(Range("A1")

When would each be used?

D





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
How do I create an IF formula with 2 logical tests FSt1 Excel Discussion (Misc queries) 0 June 16th 09 06:50 AM
How Can i use the cell colors as logical tests? kashof Excel Worksheet Functions 2 January 15th 08 08:41 PM
Multiple Logical Tests in IF function sandeep Excel Programming 4 November 9th 06 12:39 AM
VBA(Excel) tests [email protected] Excel Programming 2 September 6th 06 07:55 PM
Average a group of tests for grade, some tests not taken by all. Scafidel Excel Discussion (Misc queries) 4 August 19th 05 03:50 AM


All times are GMT +1. The time now is 02:01 PM.

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"