ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Convert hours to minutes within cell? (https://www.excelbanter.com/excel-discussion-misc-queries/38135-convert-hours-minutes-within-cell.html)

Mike

Convert hours to minutes within cell?
 
Is there a way to have a value typed into a cell automatically converted
from minutes to hours? Not a formula - at least not in the usual sense -
since the formula would be overwritten.

Thanks in advance,

Mike



Bob Phillips

Hi Mike,

Try this

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
With Target
If InStr(1, .Text, ":") 0 Then
.Value = .Value * 24 * 60
.NumberFormat = "General"
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
Is there a way to have a value typed into a cell automatically converted
from minutes to hours? Not a formula - at least not in the usual sense -
since the formula would be overwritten.

Thanks in advance,

Mike






All times are GMT +1. The time now is 06:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com