Last Updated Date of a row

shwpew

New Member
Joined
Dec 18, 2017
Messages
6
I'm looking to populate a field with the last date a row was updated. Currently, I have data in columns A - J and if any of those are updated for a given row, I would like column K of that row to be updated with that date. (I'm fine with date and time as well if that is easier). This is a spreadsheet of contact information and I want to be able to easily tell the last time I (or any user of the spreadsheet) updated the contact information for a given entry.

I have tried:
[FONT=&quot]Private Sub Worksheet_Change(ByVal Target As Range)[/FONT]
[FONT=&quot]If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub[/FONT]
[FONT=&quot]If Not Intersect(Target, Columns("B:D")) Is Nothing Then[/FONT]
[FONT=&quot] On Error Resume Next[/FONT]
[FONT=&quot] Application.EnableEvents = False[/FONT]
[FONT=&quot] Cells(Target.Row, 7) = Now[/FONT]
[FONT=&quot] Cells(Target.Row, 7).EntireColumn.AutoFit[/FONT]
[FONT=&quot] Application.EnableEvents = True[/FONT]
[FONT=&quot] On Error GoTo 0[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot]End Sub
[/FONT]
[FONT=&quot]
**AND**

[/FONT]


Private Sub Worksheet_Change(ByVal Target As Range)​
Application.EnableEvents = False​
Cells(Target.Row, "A").Value = Now()​
Application.EnableEvents = True​
End Sub​


[FONT=&quot]But get an error of "Argument Not Optional"

I have tried

[/FONT]
Private Sub Worksheet_Change(ByVal Target As Range)​
Application.EnableEvents = False​
Range("E7") = Now()​
Application.EnableEvents = True​
End Sub​

And it works, but it updates cell E7 any time any cell in the entire document is updated.

Can someone help me modify the code that worked, so that it has the limitations I require? If that's not possible, can you provide me step by step instructions of what I need to make this work? (Commented out details of what each line of code is actually doing a bonus.)

This is my first attempt at VBA so step by step instructions are greatly appreciated.

THANKS!
 
If I do it in the spreadsheet I have already created, I still get the "Argument Not Optional" message.

Additionally, worksheet_change does not come up as an pre-populated macro to run when I choose run, only "chk" does. I have to write in "worksheet_change" in order to even attempt to run it.
You cannot run a change event in that way. It should run automatically whenever any individual cell in cols A:J is changed manually (ie not by a formula). Is this not happening?
Also this
I get an error "Ambiguous name detected: Worksheet_Change" error.
suggests that you have 2 (or more) change events in the same module, which you cannot do.
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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