Ron Haynes
New Member
- Joined
- Sep 9, 2021
- Messages
- 19
- Office Version
- 2010
- Platform
- Windows
Hi All,
Below is the VBA Code to create date/time stamp and last updated date/time stamp if a cell is changed.
I need this to work with 11 different ranges, 3 of which i have listed below.
If Column "R" changes Date stamp : Column "P" Last Updated Stamp : Column "Q"
If Column "U" changes Date Stamp : Column "S" Last Updated Stamp : Column "T"
If Column "V" changes Date Stamp : Column "W" Last Updated Stamp : Column "X"
Thanks
Below is the VBA Code to create date/time stamp and last updated date/time stamp if a cell is changed.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Fabrication Timestamp Data
' TeachExcel.com
Dim myTableRange As Range
Dim myDateTimeRange As Range
Dim myUpdatedRange As Range
'Fabrication data table range
Set myTableRange = Range("R2:R4000")
'Check if the changed cell is in the data tabe or not.
If Intersect(Target, myTableRange) Is Nothing Then Exit Sub
'Stop events from running
Application.EnableEvents = False
'Column for the date/time
Set myDateTimeRange = Range("P" & Target.Row)
'Column for last updated date/time
Set myUpdatedRange = Range("Q" & Target.Row)
'Determine if the input date/time should change
If myDateTimeRange.Value = "" Then
myDateTimeRange.Value = Now
End If
'Update the updated date/time value
myUpdatedRange.Value = Now
'Turn events back on
Application.EnableEvents = True
End Sub
I need this to work with 11 different ranges, 3 of which i have listed below.
If Column "R" changes Date stamp : Column "P" Last Updated Stamp : Column "Q"
If Column "U" changes Date Stamp : Column "S" Last Updated Stamp : Column "T"
If Column "V" changes Date Stamp : Column "W" Last Updated Stamp : Column "X"
Thanks
Last edited by a moderator: