VBA – same time stamp, different cell

25 pts.
Tags:
VBA
I have a macro that runs in the background to apply time stamp to the left of where I modify the cell. So column 2, 5, 8, 11, etc is where I have a dropdown for users to pick, I want the column to the left in the same row to input time stamp. Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ErrHnd: If Target.Column = 2 Then 'disable events to stop changes made by this macro re-trigering it Application.EnableEvents = False 'only add a date if no date in column A If Not IsDate(Range("A" & Target.Row).Value) Then Range("A" & Target.Row).Value = Now Range("A" & Target.Row).NumberFormat = "dd/mmm/yy hh:mm" End If 're-enable events Application.EnableEvents = True End If Exit Sub 'error handler ErrHnd: Err.Clear 're-enable events Application.EnableEvents = True End Sub

Software/Hardware used:
Excel 2007

Answer Wiki

Thanks. We'll let you know when a new response is added.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Double
c = ActiveCell.Column
If ActiveCell.Offset(0, -1).Value “” Then
ActiveCell.Offset(0, -1).Value = Now()
Else
Exit Sub
End Sub

This should help.if not tell me what additions do you want

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    So, what is your question ? What problem are you encountering ?
    69,175 pointsBadges:
    report
  • SGTUjvari
    Right now the code only applies to writing in column 2, date/time in column 1.I want it to apply to column 5, 8, 11 and so on and apply the stamp the the colum L of them respectively.
    25 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following