Forum Discussion
matt0020190
May 13, 2024Brass Contributor
Timestamp using VBA based on specific cell changes
Hi experts, Hope you are well! I am trying to get VBA to update a cell in one column with a timestamp of when another cell changes. The attached code works well but when I use a filter on th...
- May 14, 2024
I adjusted the cell formatting again to user-defined MM/DD/YYYY hh:mm, maybe it's due to the different date settings.
Attached is the file with the customized formatting.
NikolinoDE
May 13, 2024Platinum Contributor
Attached is a modified version of your code.
At the same time, I add two files with an example as in the code and an example file with a timestamp in the cells as a comment.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub 'Editing multiple lines is caught
If Target = "" Then
Target.Offset(0, 1).ClearContents
Else
Target.Offset(0, 1) = CDate(Format(Now, "dd.mm.yyyy"))
End If
End Sub
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.
- matt0020190May 13, 2024Brass ContributorHi, thank you for this.
The range is the best option for me, but for some reason I get the debug error 😞- NikolinoDEMay 14, 2024Platinum ContributorExcel version, operating system, storage medium, ending of the saved file, etc.
All this information is needed to have a clear picture of what and why something might not work.
On two laptops where I tried the files (both with Excel 2016) it worked without any problems.- matt0020190May 14, 2024Brass Contributor
NikolinoDE Not sure on the issue but this is the error:
In addition, can this not be a function? I want to specify the columns to check and which cell the timestamp is output