Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Time format behaviour

you are placing the time value as a number, or at least it is getting
converted to a number. you can maintain it as a string to see the leading
zero

Worksheets("Sheet2").Cells(PasteRow, 16) = "'" & Format(DepTime, "HH" &
"mm")

--
Regards,
Tom Ogilvy

"Andy" wrote in message
...
I have a problem where I am copying data from one worksheet to another and

I
am also changing the time format from HH:mm to HHmm. To do this I am

using
this code.

Worksheets("Sheet2").Cells(PasteRow, 16) = Format(DepTime, "HH" & "mm")

The problem is that the hour figure does not show the leading zero even
though I have requested it, HH rather than H. The leading zero is a
requirement. To complicate matters I would only want to format the cell

to
display leading zeros as a last resort. Any ideas would be most

appreciated


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Time format behaviour

you are the one that said:

To complicate matters I would only want to format the cell to
display leading zeros as a last resort.


I guess you mellowed in the last few minutes.

--
Regards,
Tom Ogilvy

"Andy" wrote in message
...
Thanks that seems to have fixed it. However I tackled it in a different
manner. I used Worksheets("Sheet2").Cells(PasteRow, 16).NumberFormat =
"0###")
Andy

"Tom Ogilvy" wrote:

you are placing the time value as a number, or at least it is getting
converted to a number. you can maintain it as a string to see the

leading
zero

Worksheets("Sheet2").Cells(PasteRow, 16) = "'" & Format(DepTime, "HH" &
"mm")

--
Regards,
Tom Ogilvy

"Andy" wrote in message
...
I have a problem where I am copying data from one worksheet to another

and
I
am also changing the time format from HH:mm to HHmm. To do this I am

using
this code.

Worksheets("Sheet2").Cells(PasteRow, 16) = Format(DepTime, "HH" &

"mm")

The problem is that the hour figure does not show the leading zero

even
though I have requested it, HH rather than H. The leading zero is a
requirement. To complicate matters I would only want to format the

cell
to
display leading zeros as a last resort. Any ideas would be most

appreciated





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to format time in decimal format & calculate time Cheyenne Excel Discussion (Misc queries) 4 February 13th 09 04:34 PM
How to format time in decimal format & calculate time Cheyenne Excel Discussion (Misc queries) 1 February 13th 09 01:37 AM
How to format time in decimal format & calculate time Cheyenne Excel Discussion (Misc queries) 0 February 13th 09 12:49 AM
How to type format time in decimal format & calculate time Cheyenne Excel Discussion (Misc queries) 1 February 13th 09 12:09 AM
Strange "FormatCells" behaviour Mike Hyndman Excel Worksheet Functions 0 October 23rd 05 05:30 PM


All times are GMT +1. The time now is 11:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"