Auto Add Date in Multiple Columns

ddufour

New Member
Joined
Jun 18, 2012
Messages
2
Hey,

I'm trying to Auto Update a column once a preceding column is updated. For example, when I update D5, E5 will add the date. Likewise, when I update J5, K5 will add a date. It is important that the date inserted does not update with the current time of the spreadsheet, [ ie. now()]

Currently I can get one column to work with the following macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Target.Parent.Range("F:F")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, rng) Is Nothing Then Exit Sub
If Target.Value = "" Then Target.Offset(0, 1).Value = ""
If Target.Value <> "" Then Target.Offset(0, 1).Value = Now
End Sub

But I need this applied to columns A, C, F, L etc. Any help would be greatly appreciated.

Cheers,
 

drsarao

Well-known Member
Joined
Sep 9, 2009
Messages
1,112
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
c = Target.Column
If c = 1 Or c = 3 Or c = 6 Or c = 12 Then 'cols A, C, F, L
    If Target.Value = "" Then Target.Offset(0, 1).Value = ""
    If Target.Value <> "" Then Target.Offset(0, 1).Value = Now
End If
End Sub
 

Forum statistics

Threads
1,085,838
Messages
5,386,262
Members
401,989
Latest member
romandavis

Some videos you may like

This Week's Hot Topics

Top