Autoimatic Date & Time upon entry in another cell

  • Thread starter Thread starter ipick4u
  • Start date Start date
I

ipick4u

Is there a way to automatically put the current DATE in B2 & current
TIME in C2 whenever an entry is made in D2?
I would need these to be permanent entries that never change.
TIA
 
This code works on D2:D10, just adjust to suit.

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("D2:D20")) Is Nothing Then
With Target
.Offset(0, -2).Value = Format(Date, "dd mmm yyyy")
.Offset(0, -1).Value = Format(Time, "hh:mm:ss")
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.
 
Back
Top