View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Automatic time conversion in the SAME cell

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.