Display time in hours?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,535
Office Version
  1. 365
Platform
  1. Windows
Is there a way that I can enter a time value from a stopwatch as hh:ss and have it displayed as hours (hh.hh)?

For example, I'd like to enter "7:45" in a cell and have "7.75" displayed in that cell. I know I can do it by entering the "7:45" in A1 and use a formula in B1 (=A1*24) to convert it from days to hours and then format it as "0.00". But is there a way I can do it in the same cell?

Thanks
 
Yes, the "?" is a digit placeholder, like "0" but for spaces.

The "?/2400" is a format for displaying numbers as simple fractions, namely, as twenty-four-hundredths. Similarly, "?/2" is a format for displaying numbers as halves, etc.

Interesting. Is this documented somewhere? I couldn't find it.

I ran a few simple tests.

R/CCDEFGHIJKL
5CF->?/1?/2?/3?/4?/10#/100/1000/100.0/10
611/12/23/34/410/1010/1010/1010/10error
722/14/26/38/420/1020/1020/1020/10error
833/16/29/312/430/1030/1030/1030/10error
91.52/13/25/36/415/1015/1015/1015/10error
100.10/10/20/30/41/101/101/1001/10error
110.20/10/21/31/42/102/102/1002/10error
120.250/11/21/31/43/103/103/1003/10error
130.51/11/22/32/45/105/105/1005/10error

<tbody>
</tbody>

A few observations:


  1. It appears that it rounds the number on the left (rather than truncating).
  2. The "#" and ")" codes also work (in addition to "?").
  3. No other formatting codes are allowed to the left of the "/".

So what is this good for? I can't imagine where I'd use it?
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If your objective is purely ' Cosmetic '... :wink:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
    If Target = "" Then
    Dim Sh As Shape
        For Each Sh In Shapes
           If Not Application.Intersect(Sh.TopLeftCell, Target) Is Nothing Then
             If Sh.Type = msoTextBox Then Sh.Delete
           End If
        Next Sh
        Exit Sub
    Else
        If IsNumeric(Target) Then
            Dim myTextBox As TextBox
            With Target
                Set myTextBox = .Parent.TextBoxes.Add(Top:=.Top, Left:=.Left, Width:=.Width, Height:=.Height)
            End With
            Application.EnableEvents = False
                With myTextBox
                    .Caption = Target * 24
                    .VerticalAlignment = msoAnchorCenter
                    .HorizontalAlignment = msoAnchorCenter
                End With
            Application.EnableEvents = True
        End If
    End If
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Target.Select
End Sub
 
Upvote 0
If your objective is purely ' Cosmetic '... :wink:

Wowie Zowie!!!

That is so far over my head that I can't even imagine how long it would take for me to comprehend what it is doing. :confused:

I give you the VBA Wizard award for this one. (y)
 
Upvote 0
Unless I'm having a full scale brainfart, a custom format of [h]\.mm should do what you're asking.

;) Unless I'm having one, all that does is replace the ":" with a ".". I want "7:45" to display as "7.75". That is, 7 hours and 45 minutes is to display as 7.75 hours. No?
 
Upvote 0
And with that I'm going to leave quitely, hoping nobody noticed that I was here...
 
Upvote 0
Wowie Zowie!!!

That is so far over my head that I can't even imagine how long it would take for me to comprehend what it is doing. :confused:

I give you the VBA Wizard award for this one. (y)

Thanks a lot for your very kind words ... :)
 
Upvote 0

Forum statistics

Threads
1,215,617
Messages
6,125,867
Members
449,266
Latest member
davinroach

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