Forum Discussion
Date of Last Modified for a Cell
After reopening the workbook, and if asked, allowing macros, change the value of a cell in column A from A2 down. The date should appear in the corresponding cell of column B.
Also, how can I set it up to update the date and time of last edit if something in columns G through J were edited? Or in columns C, E, F, J, K?
- JahtibaCSep 25, 2024Copper Contributor
washcaps2 I HansVogelaar I got up to this point following along but I am getting the 12:00 AM error. What was the solution to give the actual time? Thank you.
- washcaps2Oct 06, 2023Copper ContributorYeah I think the problem was when I inserted a column. It then put the last edit time in all rows to the end. Should be good now. Thanks again!
- HansVogelaarOct 06, 2023MVP
Did you perhaps do something that caused the code to enter the date and time in ALL rows of column K? If so, do the following:
- Activate the Visual Basic Editor.
- Press Ctrl+G to activate the Immediate window.
- Type (or copy/paste) the line Application.EnableEvents = False
- With the insertion point in that line, press Enter.
- Switch back to Excel.
- Select all rows from the row below the "real" used range of the sheet to the very last row 1048576.
- Right-click in the selection and select Delete.
- Activate the Visual Basic Editor.
- Press Ctrl+G to activate the Immediate window.
- Type (or copy/paste) the line Application.EnableEvents = True
- With the insertion point in that line, press Enter.
- Switch back to Excel.
- Save the workbook.
- washcaps2Oct 06, 2023Copper Contributor
- washcaps2Oct 06, 2023Copper Contributor
HansVogelaar Did this screenshot work? It's the error message I get
- HansVogelaarOct 06, 2023MVP
That must have another cause. The code doesn't impose a limit.
- washcaps2Oct 06, 2023Copper Contributor
Thanks, that worked. Only problem I'm having is that I can't insert rows as it says the limit is exceeded. I'll only ever need 200 rows or so. Can I limit it to 200 rows instead of the million?
- HansVogelaarSep 29, 2023MVP
Let's say you want the timestamp in column M.
Use this variation of the code posted higher up:
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Range("C2:C" & Rows.Count & ",E2:F" & Rows.Count & _ ",J2:K" & Rows.Count), Target) Is Nothing Then Application.ScreenUpdating = False Application.EnableEvents = False Intersect(Range("M:M"), Intersect(Range("C2:C" & Rows.Count & _ ",E2:F" & Rows.Count & ",J2:K" & Rows.Count), Target).EntireRow).Value = Now Application.EnableEvents = True Application.ScreenUpdating = True End If End Sub - washcaps2Sep 29, 2023Copper Contributorfigured out the time part