Thread: time error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default time error

On Sun, 26 Jun 2005 07:53:02 -0700, SMH wrote:

I have an application in EXCEL using macros. The program has to read an empty
cell which should give a value 12:00:00 AM for all blank empty cells. On one
machine it works but on a another PC this does not work.

The cell when read (using the same spreadsheet) reads 00:00:00 rather than
12:00:00 AM or PM in the second machine. I have tried all sorts of formats
and even entered 12:00:00 PM in the cell but the value read is always
00:00:00 and so themacro does not work on the second machin.First machine is
running window xp professional and the second machine (where the problem is )
is running windows home. Both machines are running the same version of excel.

What is the cell format that I should enter in the second machine so the the
cells will read 12:00:00 rather than 00:00:00


h:mm:ss AM/PM

However, the cell format is NOT your problem.

The cell format only controls what is DISPLAYED in the cell. It has no effect
over what is STORED in that cell. The Value (or contents) (cell.value) of a
cell that displays the time 12:00:00 AM is zero (0), and the Value of a cell
that displays the time 12:00:00 PM will be 0.5.

Perhaps a more robust fix for your macro would be to look at the .value
property rather than the .text property of the cells you are checking.

Here are some examples:

?[a1].text
12:00:00 AM
?[a1].value
0
?[a2].text
12:00 PM
?[a2].value
0.5


--ron