#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Format Time

Option Explicit
Sub testme()
Dim RangeTotals As Double
RangeTotals = 27.1998611111111 'my test data!
With ActiveCell.Offset(0, 6)
.NumberFormat = "[hh]:mm:ss"
.Value = RangeTotals
End With
End Sub



stottle wrote:

Hello,

I have totalled up a column of cells which contain a time and when i
highlight all the cells and use the sum option in the bottom right of
excel (it gives you the option of sum, max, min, ave etc if you right
click there) it shows the value 652:47:46 (652 hours, 47 minutes and
46 seconds).

But when i use the format function in VBA, I get 04:47:48 (RangeTotals
is Variant which contains the number I would like to display)

ActiveCell.Offset(0, 6).Value = Format(RangeTotals, "Long Time")

When the time is formatted as a decimal i get 27.1998611111111.

Can someone help me so that the activecell value = 652:47:46 instead
of 04:47:48.

Many Thanks

Stuart


--

Dave Peterson
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
Remove time from a date and time field? Format removes the displa. oaoboc Excel Worksheet Functions 1 February 16th 05 07:20 PM


All times are GMT +1. The time now is 08:36 PM.

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

About Us

"It's about Microsoft Excel"