change mm to decimal

C

cpliu

If it's 22 min, I enter =22/60 to get 0.37. Is there a faster way that
I can enter just 22 and it converts to 0.37 for me and I still have
the option to see it in minutes if chosen?

Thanks,
 
G

Gord Dibben

With formulas..................

In B1 enter this formula.

=IF(A1="","",A1/60)

Drag/copy down as far as you wish.

Cell will be blank until a number is entered in column A

With event code..................

This code will add the decimal value to adjacent cell.

Private Sub Worksheet_Change(ByVal Target As Range)
Const myRange As String = "A1:A10" 'adjust to suit
On Error GoTo endit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(myRange)) Is Nothing Then
With Target
.Offset(0, 1).Value = Format(.Value / 60, "0.00")
End With
End If
endit:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on sheet tab and "View Code"

Copy.paste the code into that sheet module. Edit range to suit.

Alt + q to return to Excel.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top