Time Stamp in Column A

rubinda

New Member
Joined
Jun 26, 2018
Messages
36
I am trying to enter a time stamp into column A when data is entered into column E, for a row, and I need the macro to loop through column E, and anywhere it is not blank place the time stamp in column A.
If data is entered E2 (E3, E4, E5, etc.) once the time stamp is entered into cell A[X], I need it to remain the same.
I have started with the code below, but not sure where to go from here. Can you please assist?

Sub timestamp()
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
With Target
If .Value <> "" Then
.Offset(0, 1).Value = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM")
End If
End With
End If
enditall:
Application.EnableEvents = True
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
First off you need this to be in the Worksheet Change Event.
Right click the sheet you want this to happen on. Click on View Code and paste the below code into the Visual Basic Editor.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, d As Range
Set d = Intersect(Target, Range("E2:E" & Rows.Count))
If d Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each c In d
    If c <> "" And Range("A" & c.Row) = "" Then Range("A" & c.Row) = Format(Now, "mm/dd/yyyy hh:mm:ss AM/PM")
Next
Application.EnableEvents = True
End Sub
 
Upvote 0
Did you change anything in the code?

Can you post it exactly as you have it?
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,824
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top