View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
megs megs is offline
external usenet poster
 
Posts: 6
Default Automatic time conversion in the SAME cell

No more rocks, thanks JE. Problem solved. :)

"JE McGimpsey" wrote:

but what if I wanted to specify a range of cell?


Then you probably should have specified that in your problem statement,
in which you wrote about a single cell.

Any other rocks to bring?

This modification will work for A4:C22:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const nHours As Long = 6
Dim dTimeAdjust As Double
With Target
If .Cells.Count 1 Then Exit Sub
If Not Intersect(.Cells, Me.Range("A4:C22")) Is Nothing Then
If Not IsEmpty(.Value) Then
On Error Resume Next
dTimeAdjust = nHours / 24
Application.EnableEvents = False
.Value = .Value - dTimeAdjust - _
(.Value <= dTimeAdjust)
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End With
End Sub



In article ,
Megs wrote:

Thank you JE, it works for a single cell, but what if I wanted to specify a
range of cell? Like the following:
1. The entire workbook or
2. A4 to C22?