Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I create an IF formula with 2 logical tests | Excel Discussion (Misc queries) | |||
How Can i use the cell colors as logical tests? | Excel Worksheet Functions | |||
Multiple Logical Tests in IF function | Excel Programming | |||
VBA(Excel) tests | Excel Programming | |||
Average a group of tests for grade, some tests not taken by all. | Excel Discussion (Misc queries) |