View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Excel 2010 If Then logic - with time

"MyVeryOwnSelf" wrote:
I would like to use a time format as the logical
test and the statement does not seem to recognize
the time format.

[....]
If you're trying to test if a cell is in the time format
or not, take a look at the function CELL(info_type, [reference])
with info_type="format".


Caveat lector: CELL("format",A1) recognizes only some time formats. For
example, for hh:mm:ss, it returns "D8". But it returns "G" for [h]:mm:ss, a
common alternative.

Moreover, CELL is not recalculated if you only change the referenced cell's
format. So you must recalculate the cell that uses CELL manually, in one of
several ways.

IMHO, it is "bad practice" to use the cell's format as a formula condition.
But viable alternatives can only be suggested if/when the "rmscg15" explains
why he/she wants to rely on the cell format in the first place.