john tempest
Board Regular
- Joined
- Nov 20, 2005
- Messages
- 54
i need to put the current time in cell (A1) and the current date in cell (D5) when a value is entered in (A3)
thank you
johyn tempest
thank you
johyn tempest
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$A$3" Then
Range("A1") = Time
Range("D5") = Date
End If
Application.EnableEvents = True
End Sub
If Target.Address = "$B$10" Then
Range("A10").Value = Format(Time, "h:mm")
Range("G10").Value = Format(Date, "mm/dd/yy")
End If
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'if the changed cell was within the range B10:B40
If Not Intersect(Target, Range("B10:B40")) Is Nothing Then
'insert time in column A of the same row
Cells(Target.Row, "A").Value = Time
'insert date in column G of the same row
Cells(Target.Row, "G").Value = Date
End If
Application.EnableEvents = True
End Sub