Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default easiest way to convert a number to hours


i am adding up some time durations and storing it in a variable. when the
variable is greater than 1, 1.384 for example, i need to format it in hours and
minutes and put the value in a cell. i keep only getting the hours greater than
24, 9:13:04, in this case.

format(variablename,"hh:mm:ss") is what i tried.

is there a way to format the number rather than doing the math to get 33:13?
--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default easiest way to convert a number to hours

this seems to work

"[HH]:mm:ss;@"

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...

i am adding up some time durations and storing it in a variable. when the
variable is greater than 1, 1.384 for example, i need to format it in hours
and minutes and put the value in a cell. i keep only getting the hours greater
than 24, 9:13:04, in this case.

format(variablename,"hh:mm:ss") is what i tried.

is there a way to format the number rather than doing the math to get 33:13?
--


Gary





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default easiest way to convert a number to hours

Hi Gary,

I could not get your answer to work with Format function in xl2002 or
xl2007. However, the following worked in both versions:-

WorksheetFunction.Text(1.384, "[h]:mm:ss")

--
Regards,

OssieMac


"Gary Keramidas" wrote:

this seems to work

"[HH]:mm:ss;@"

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...

i am adding up some time durations and storing it in a variable. when the
variable is greater than 1, 1.384 for example, i need to format it in hours
and minutes and put the value in a cell. i keep only getting the hours greater
than 24, 9:13:04, in this case.

format(variablename,"hh:mm:ss") is what i tried.

is there a way to format the number rather than doing the math to get 33:13?
--


Gary






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default easiest way to convert a number to hours

thanks for checking.

i put 1.38 in cell and recorded the macro when i manually formatted the cell
and this is what it showed:
Selection.NumberFormat = "[h]:mm:ss;@"


the format didn't work the first time i tried it, but when i went back and tried
it again, it did. i didn't know why it changed, but since it worked, i posted
it.

but i ended up just using this:
..NumberFormat = "[h]:mm:ss"
--


Gary


"OssieMac" wrote in message
...
Hi Gary,

I could not get your answer to work with Format function in xl2002 or
xl2007. However, the following worked in both versions:-

WorksheetFunction.Text(1.384, "[h]:mm:ss")

--
Regards,

OssieMac


"Gary Keramidas" wrote:

this seems to work

"[HH]:mm:ss;@"

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...

i am adding up some time durations and storing it in a variable. when the
variable is greater than 1, 1.384 for example, i need to format it in hours
and minutes and put the value in a cell. i keep only getting the hours
greater
than 24, 9:13:04, in this case.

format(variablename,"hh:mm:ss") is what i tried.

is there a way to format the number rather than doing the math to get
33:13?
--


Gary








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
Convert a number to Hours, Minutes, etc. berniean Excel Discussion (Misc queries) 3 August 8th 09 05:10 PM
Convert Number in to Hours.... DR Excel Worksheet Functions 3 March 24th 09 01:42 AM
Convert dd:hr:mn:ss to Decimal number of hours Virginia Excel Discussion (Misc queries) 1 April 17th 07 04:56 AM
Convert Total Hours and Minutes to Whole Number BobS9895 Excel Worksheet Functions 3 April 13th 06 07:56 PM
Is it possible to convert a number into hours and minutes le clef Excel Worksheet Functions 4 April 1st 06 05:43 PM


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