Dragging down a formula in VBA - last updated cell

jkes813

New Member
Joined
Sep 11, 2013
Messages
5
I am trying to make a column (Column AM) in an excel spreadsheet that automatically populates "Last Updated" only when any info within that row is updated (not the whole sheet).

The code I have in VBA populates a single cell, but I can't drag it down to fill in the rest. I would like to populate the whole column so that when any info in one row is updated, the last updated field in that row shows today's date.

The code I have for the single cell is:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng1 As Range
Set rng1 = Intersect([a3:al3], Target)
If rng1 Is Nothing Then Exit Sub
Application.EnableEvents = False
[am3] = Format(Now(), "mm-dd-yyyy hh:mm:ss")
Application.EnableEvents = True
End Sub

Thanks in advance for your help! I will use this all the time if this works!!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Welcome to the Board!

You can expand the Target range to the full column area, then identify the Target.Row:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng1 As Range
    Set rng1 = Intersect([A:AL], Target)
    If rng1 Is Nothing Then Exit Sub
    Cells(Target.Row, "AM").Value = Format(Now(), "mm-dd-yyyy hh:mm:ss")
End Sub

HTH,
 
Upvote 0
Thank you so much! Just what I needed! :)

Welcome to the Board!

You can expand the Target range to the full column area, then identify the Target.Row:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng1 As Range
    Set rng1 = Intersect([A:AL], Target)
    If rng1 Is Nothing Then Exit Sub
    Cells(Target.Row, "AM").Value = Format(Now(), "mm-dd-yyyy hh:mm:ss")
End Sub

HTH,
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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