There is a solution! Place this VBA code in your worksheet module, i.e.:
- Open the Visual Basic Editor (Alt-F11)
- In the top left treeview, double click on the sheet you want to enter your times
- In the central code panel, place the below code.
- 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
59, format the cell as[MM]:SS. Like:02:10:45would then display as130:45instead. But apparently that does not work for inputs. – Arjan Jan 20 '11 at 09:16