Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
ditchy
 
Posts: n/a
Default convert numbers to time

Hello I need some help creating a macro that will convert number pad
time to 0:00:00,
What the macro needs to do is check the Column or Cells to see what
format is used. If format is "0.00" or "general", convert to time with
this formula,
=(INT(A1)+MOD(A1,1)*100/60)/1440 (or an equivalent formula) and then
format to 0:00:00.
If the Column or Cells formated as 0:00:00 leave as is.Is this possible
to achieve?,
there is a lot of data I would like to convert in multiple columns and
cells
thank you
Ditchy, Ballarat

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default convert numbers to time

Select the cells you want to convert and try running this macro.

Option Explicit
Sub testme02()
Dim myCell As Range
Dim myRng As Range

Set myRng = Selection

For Each myCell In myRng.Cells
With myCell
If .NumberFormat = "General" _
Or .NumberFormat = "0.00" Then
.Value _
= (Int(.Value) + ((.Value - Int(.Value)) * 100 / 60)) / 1440
.NumberFormat = "hh:mm:ss"

End If
End With
Next myCell

End Sub

Remember to save before you run it. If it's wrong, you'll want to close without
saving.

ditchy wrote:

Hello I need some help creating a macro that will convert number pad
time to 0:00:00,
What the macro needs to do is check the Column or Cells to see what
format is used. If format is "0.00" or "general", convert to time with
this formula,
=(INT(A1)+MOD(A1,1)*100/60)/1440 (or an equivalent formula) and then
format to 0:00:00.
If the Column or Cells formated as 0:00:00 leave as is.Is this possible
to achieve?,
there is a lot of data I would like to convert in multiple columns and
cells
thank you
Ditchy, Ballarat


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
ditchy
 
Posts: n/a
Default convert numbers to time

Thank you Dave
this is perfect
much appreciated,
regards
Ditchy

Dave Peterson wrote:
Select the cells you want to convert and try running this macro.

Option Explicit
Sub testme02()
Dim myCell As Range
Dim myRng As Range

Set myRng = Selection

For Each myCell In myRng.Cells
With myCell
If .NumberFormat = "General" _
Or .NumberFormat = "0.00" Then
.Value _
= (Int(.Value) + ((.Value - Int(.Value)) * 100 / 60)) / 1440
.NumberFormat = "hh:mm:ss"

End If
End With
Next myCell

End Sub

Remember to save before you run it. If it's wrong, you'll want to close without
saving.

ditchy wrote:

Hello I need some help creating a macro that will convert number pad
time to 0:00:00,
What the macro needs to do is check the Column or Cells to see what
format is used. If format is "0.00" or "general", convert to time with
this formula,
=(INT(A1)+MOD(A1,1)*100/60)/1440 (or an equivalent formula) and then
format to 0:00:00.
If the Column or Cells formated as 0:00:00 leave as is.Is this possible
to achieve?,
there is a lot of data I would like to convert in multiple columns and
cells
thank you
Ditchy, Ballarat


--

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
Function to convert Time String to Time Andibevan Excel Worksheet Functions 6 August 19th 05 01:19 PM
convert interval to various separate date , time, hr, minutes Todd F. Excel Worksheet Functions 4 July 12th 05 07:25 PM
how do I convert a date and time column to a time column thdorsky2 Excel Worksheet Functions 1 March 4th 05 08:49 PM
Convert text to numbers gennario Excel Discussion (Misc queries) 6 January 10th 05 11:56 PM
How to convert Numbers to text Calif_guy Excel Worksheet Functions 1 November 12th 04 05:12 AM


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