View Single Post
  #5   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

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?


"JE McGimpsey" wrote:

One way:

Put this in your worksheet code module (right-click the worksheet tab
and choose View Code from the pop-up menu):

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 .Address(False, False) = "A4" 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:

If I key in the time "9:00:00 AM" in cell A4 and press the enter key, I
wanted cell A4 to display "3:00:00 AM". If this is possible, please tell me
the detailed procedure.

For your information, "9:00:00 AM" is the U.S. time, once I entered the
time excel in cell A4 for example, it should automatically become "3:00:00
AM" in German time in the SAME A4 cell.