View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default Time Format in VBA doesn't match Excel display

If you posted the line of code, I'd expect like Tom said that you did not
include .text but used either .value or defaulted to .value
when you specified the cell.


"LabElf" wrote ...
Thank you. I'm not reading the active cell, but using the Text property of
the cell I'm reading does give me the displayed value, as you described.
--
Assigning guilt doesn't solve the problem


!! and if you have a problem and can't identify the culprit
!! how are you going to fix the problem. So I disagree.
!! I think perhaps you are mixing punishment with solution.
!! How about -- If you don't have a problem -- don't fix it.


"Tom Ogilvy" wrote:

ActiveCell.Text

will give you the displayed value of the cell.

--
regards,
Tom Ogilvy

"LabElf" wrote in message
...
So far I've only tested this in Excel 2000, but a final solution would

have
to work in Excel 2003 as well.

I'm reading data from cells in an Excel sheet and using the data to
construct ascii text files. The particular problem I have is this:
The cell I'm reading displays as "113:00:00" in Excel
The format of the cell is Category - Time, Type - 37:30:55 (and the sample
area shows "113:00:00" at this point.
The formula bar shows "1/14/1900 5:00:00 PM"
When reading the cell in my VB program, the raw value of the cell is
"4.70833333333333"
The NumberFormat property of the cell is "[h]:mm:ss"
When I read the cell with this number format (using the Format function),

I
get the string ":01:00". The user would expect to see "113:00:00", which
Excel shows him is there.

How can I get the value that Excel is displaying, since using NumberFormat
doesn't work? (I know I could just tell the users to use straight text or
General format, but I would like to accommodate the users' desire to use
Excel formats to make their work easier.)
--
In theory, there is no difference between theory and practice; in

practice,
there is.