Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel number formats 2

Status
Not open for further replies.

petermeachem

Programmer
Joined
Aug 26, 2000
Messages
2,270
Location
GB
I'm producing an excel from vb. This shows driver's times for each day in the form 09:45 and a total. If I click on a cell containing 09:45, excel shows 09:45:00 in the edit box thing at the top and the cell format is Custom hh:mm. If the cell contains more than 24 hrs it shows 01/01/1900 13:15:00 for a time of 37.15.
I've tried various (many) formats to stop this like
vbExcel.ActiveWorkBook.Sheets(1).Range("D3:D" & iRow + 3).NumberFormat = ???
but I can't find one that will tell Excel to just leave the thing alone and not to get all clever with my data.
If I record a macro to format a cell as text, the macro says
NumberFormat = "@"
This just gives me values like 1.52345

Well stuck, I now dislike excel as much as I dislike Crystal.

 
Hi,

Use the custom format...
[tt]
[h]:mm:ss
[tt]
it roll DAYS into hours

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
...but will still display in the "edit box thing" above as 1/1/1900 1:15:00 PM.

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 

Code:
With TheCell
  .NumberFormat = "[h]:mm:ss"
End With


Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top