Getting Decimal value into time value

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,180
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
A while ago I had gotten this formula from MarkW it works great. We get different spreadsheet in from vendors and the problem is that the time values are all formatted wrong. What I would like to get is to get all values out of decimal and into time value. If the formula for the row gives me 28.6 or 39.3 I would like to get that into a time value. Can anyone help me using the same setup below!

Thanks in advance Stephen
formulas for time.xls
ABCDEFG
1OctNovDecJanFebMar
261314841
346616
481261440
563514
6645621
710121133
855
91418:301244.5
1012:171126.349.6
110
1212.311:20528.6
1381615.339.3
145611
1533410
Sheet1
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi Stephen

Just adjust your formula

=SUM(IF(TEXT(A2:D2,"hh:mm:ss")+0=A2:D2,1,1/24)*A2:D2)
This is an array formula and so MUST be entered with CTRL+SHIFT+ENTER and not just ENTER.

and format column G as [h]:mm.

Hope this helps
PGC
 
Upvote 0
Here's a code approach
Code:
Sub ConvertMe()
    Dim cl As Range
    For Each cl In Selection
        If Application.WorksheetFunction.IsNumber(cl) Then
        Application.EnableEvents = False
        cl = Evaluate("=dollarfr(" & cl & ",60)")
        cl.Replace What:=".", Replacement:=":", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        Cells.Find(What:=".", After:=cl, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
        End If
    Next cl
End Sub

NOTE: Analysis ToolPak required.

lenze
 
Upvote 0
It's been about a year since this thread, I ran into another problem. If the cell is formated as text then I get a problem with the formula. If I use the formula with just a1:b1 I get the correct answer but wh n the cell is formatted as text then the formula bottoms out. COuld someone please guide me.

Thanks in advance Stephen
Book3
ABCDEFGH
1GeneralTimeTextFormatted as [h]:mmShould be
24.54:304:309:1113:30
3
4
5
6
7
8
9
10
11
12
13
14
Sheet2
 
Upvote 0
This worked for me:

=SUM(IF(ISNUMBER(A2:C2),IF(TEXT(A2:C2,"hh:mm:ss")+0=A2:C2,1,1/24)*A2:C2,TEXT(A2:C2,"hh:mm:ss")+0))

Don't forget Ctrl+Shift+Enter.
 
Upvote 0

Forum statistics

Threads
1,225,727
Messages
6,186,683
Members
453,368
Latest member
xxtanka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top