Forum Discussion
maceslin
Feb 17, 2021Copper Contributor
Auto update a date
How do I have a cell auto update with the current date whenever a value in its row changes Thanks Dave
HansVogelaar
Feb 17, 2021MVP
Let's say that you want the current date/time in column M whenever a cell in columns A to L is changed by the user.
Right-click the sheet tab.
Select 'View Code' from the context menu.
Copy the following code into the worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rw As Range
If Not Intersect(Range("A:L"), Target) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each rw In Intersect(Range("A:L"), Target).Rows
Range("M" & rw.Row).Value = Now
Next rw
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
Switch back to Excel.
Save the workbook as a macro-enabled workbook (.xlsm).
Make sure that you allow macros when you open the workbook.
maceslin
Feb 17, 2021Copper Contributor
Works perfectly until I upload it to Google Docs for sharing with others. It appears Google docs does not support macro-enabled workbooks. Any other ideas
- HansVogelaarFeb 17, 2021MVP
VBA indeed doesn't work on the web. I don't know of a solution for that, sorry.
- maceslinFeb 17, 2021Copper Contributor
HansVogelaar thanks for the help