Thread: Logical tests
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
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