19

I want to enter time data into excel sheet in mm:ss format. The problem is - that although the cell format is mm:ss, if I enter the data like this:

12:33 the actual value stored is 12 hours and 33 min. if I want 12 min and 33 sec, I need to enter 0:12:33

Is there a way to make the cell accept 12:33 as mm:ss ?

Dave
  • 25,405
Dani
  • 743
  • 2
    To display minutes larger than 59, format the cell as [MM]:SS. Like: 02:10:45 would then display as 130:45 instead. But apparently that does not work for inputs. – Arjan Jan 20 '11 at 09:16

8 Answers8

16

As answered by Steve, Excel interpret user input 12:33 as 12h33m. You cannot change this behavior of how Excel accepts user input.

As you mentioned in comment, users would input 12:33 but meaning 12m33s.

Here is an workaround solution to get the correct value for calculation.

  1. Format cell A1 (user input, eg. 12:33) as [h]:mm
  2. Enter formula =A1/60 in cell B1
  3. Format cell B1 as [m]:ss

The displayed value should be the same in A1 & B1. However, B1 will be the actual value you want.

wilson
  • 5,002
  • 2
  • 22
  • 39
9

Time is universally entered in Hours:Minutes:Seconds format, so you can't change this entry format. You can obviously change the display format, but unfortunately you'll need to abide by the entry format.

Steve
  • 2,831
  • 17
  • 68
  • 120
4

There is a solution! Place this VBA code in your worksheet module, i.e.:

  1. Open the Visual Basic Editor (Alt-F11)
  2. In the top left treeview, double click on the sheet you want to enter your times
  3. In the central code panel, place the below code.
  4. Close VBE

Use this code:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Value < 0 Or Target.Value > 1 And Target.NumberFormat <> "h:mm" Then Exit Sub
    Application.EnableEvents = False
    Target.Value = Target.Value / 60
    Target.NumberFormat = "mm:ss"
    Application.EnableEvents = True
End Sub

In case you already formatted the range you're entering the data in, use this line instead as the first line:

If Target.Value < 0 Or Target.Value > 1 Then Exit Sub

Note that this will change the value and format - every time you enter either a time - or something that is between 0 and 1! If you want to restrict it to a certain column, add this line:

If Target.Column <> 3 Then Exit Sub

or this line to restrict it to a certain range

If Intersect(Target, Range("A2:A100") Is Nothing Then Exit Sub
Peter Albert
  • 2,970
3

Easiest way to work out hours completed

Format the Cell (A1) hh:mm

Input as normal (07:22)

Format the Cell (B1) hh:mm

Input as normal (16:00)

Format the Cell (C1) h:mm

Input all data into cell (C1) the following: =(A1+B1)/60

Don_T
  • 31
  • At first I thought this was a more cumbersome duplicate of wilson's answer, which suggests using separate display column that shows the number in the data entry column divided by 60. But on a closer look it's not even clear to me what this is purported to accomplish, much less how it pertains to the question. The question wasn't about determining the total hours of two columns (which I presume is what you mean by "work out hours completed"), but your answer doesn't accomplish that anyway, it takes the total of A and B and displays the hours portion as minutes. – Adi Inbar Jul 27 '23 at 21:42
1

I find it best to enter the minutes in column A then the seconds in column B. Then you can Sum the columns. All as normal number format.

Next convert seconds > 60 to minutes by dividing the sum in col B by 60 and add the INT to the Col A Sum and leave the remainder MOD in col B.

Alternatively you can have col C as decimal number by having a formula = (A1+(B1/60)) will give decimal minutes. At the bottom of Col C do a sum then apply a formula to convert the decimal portion back to Seconds as follows say C22 is where the sum is held then in C23 enter formula =MOD(C22,1)*60.

Now in A23 enter formula =INT(C22) to show Total minutes including those from the sum in C22.

MartinCC
  • 11
  • 1
1

I've had the same issue and here's the solution I've found: Enter the formula using the TIME function, which creates a time matrix as =TIME(H,M,S) and format it as you please. You still have to enter 0 hours every time because maths but this makes the whole thing infinitely more workable.

1

Highlight the cell(s)/column which you want as Duration, right click on the mouse to "Format Cells". Go to "Custom" and look for "h:mm" if you want to input duration in hour and minutes format. If you want to include seconds as well, click on "h:mm:ss". You can even add up the total duration after that.

Hope this helps.

0

Solution to above. When using the h:mm format, excel will not let you go above 23. Add brackets to the hours in your format [h]:mm and you are free to go above 23.

To calculate the value in seconds, set the cell to "general" number format and then type the following formula

=HOUR(A1)*60+MINUTE(A1)
Excellll
  • 12,717
  • The question had nothing to do with calculating the number of seconds of a time value shown in hours and minutes. It was about changing how Excel interprets data entry of time values, specifically, how to get Excel to show a time value entered as two numbers separated by a colon as minutes and seconds rather than hours and minutes. It's not about calculating anything. – Adi Inbar Jul 27 '23 at 21:53