Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default TextBox in UserForm with 24h time format

Hi,

I would like to sum up several time values from different
cells (more than 24 h) and output them into a TextBox
(UserForm).

The result should be 26:30 but the TextBox shows 09:30.

I tried it like:
TextBox1 = Format(Application.Sum(Range _
("A1:A10")), "hh:mm")

Unfortunately it doesn't work.

I tried it with the format [h]:mm but it shows :12.

Is there a possibility to get the needed formatting?

Thanks for your help,
Mika
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default TextBox in UserForm with 24h time format

One way:

Dim dblTime as Double
Dim lDays as long, lHours as long, lMinutes as long
dblTime = Format(Application.Sum(Range _
("A1:A10")), "hh:mm")
lDays = Int(dblTime)
lhours = hour(dblTime-int(dblTime))
lMinutes = minute(dblTime-int(dblTime))
Textbox1.Text = lDays*12+lHours & ":" & format(lMinutes,"00")

--
Regards,
Tom Ogilvy



"Mika" wrote in message
...
Hi,

I would like to sum up several time values from different
cells (more than 24 h) and output them into a TextBox
(UserForm).

The result should be 26:30 but the TextBox shows 09:30.

I tried it like:
TextBox1 = Format(Application.Sum(Range _
("A1:A10")), "hh:mm")

Unfortunately it doesn't work.

I tried it with the format [h]:mm but it shows :12.

Is there a possibility to get the needed formatting?

Thanks for your help,
Mika



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
Date Format for Userform TextBox John Calder New Users to Excel 4 July 29th 09 10:19 PM
TextBox on a userform - format to currency & percent Terry Excel Discussion (Misc queries) 2 September 12th 08 02:46 PM
format textbox in userform jeffP Excel Programming 1 January 25th 05 02:10 AM
Format of a TextBox in a userform MD Excel Programming 4 January 13th 05 06:42 PM
Qn: Date Format in TextBox in UserForm? Michael Vaughan Excel Programming 1 August 23rd 04 10:03 AM


All times are GMT +1. The time now is 09:22 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"