Multiple Date / Time Stamp and Updated Date /Time Stamp

Ron Haynes

New Member
Joined
Sep 9, 2021
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
Hi All,

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:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Is that last criteria correct, as it does not match the previous two?
 
Upvote 0
HI Fluff,

See below for all the ranges. I am new to VBA so I may be asking for something that cant be done.
What I am asking for is if a cell in Column R changes then the cell in column P and Q on the same row get the date stamp and updated date stamp.

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"
If Column "AB" changes Date Stamp : Column "Z" Last Updated Stamp : Column "AA"
If Column "AE" changes Date Stamp : Column "AC" Last Updated Stamp : Column "AD"

If Column "AI" changes Date Stamp : Column "AF"
If Column "AM" changes Date Stamp : Column "AJ"
If Column "AQ" changes Date Stamp : Column "AN"
If Column "AU" changes Date Stamp : Column "AR"
If Column "AY" changes Date Stamp : Column "AV"
If Column "BK" changes Date Stamp : Column "BI" Last Updated Stamp : Column "BJ"
If Column "BQ" changes Date Stamp : Column "BP"

Regards
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("R:R,U:U,V:V,AB:AB,AE:AE,AI:AI,AM:AM,AQ:AQ,AU:AU,AY:AY,BK:BK,AQ:BQ")) Is Nothing Then
      Select Case Target.Column
         Case 18, 21, 28, 31, 63
            Target.Offset(, -1).Value = Now
            If Target.Offset(, -2).Value = "" Then Target.Offset(, -2).Value = Now
         Case 22
            Target.Offset(, 2).Value = Now
            If Target.Offset(, 1).Value = "" Then Target.Offset(, 1).Value = Now
         Case 35, 39, 43, 47, 51
            Target.Offset(, -3).Value = Now
         Case 69
            Target.Offset(, -1).Value = Now
      End Select
   End If
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("R:R,U:U,V:V,AB:AB,AE:AE,AI:AI,AM:AM,AQ:AQ,AU:AU,AY:AY,BK:BK,AQ:BQ")) Is Nothing Then
      Select Case Target.Column
         Case 18, 21, 28, 31, 63
            Target.Offset(, -1).Value = Now
            If Target.Offset(, -2).Value = "" Then Target.Offset(, -2).Value = Now
         Case 22
            Target.Offset(, 2).Value = Now
            If Target.Offset(, 1).Value = "" Then Target.Offset(, 1).Value = Now
         Case 35, 39, 43, 47, 51
            Target.Offset(, -3).Value = Now
         Case 69
            Target.Offset(, -1).Value = Now
      End Select
   End If
End Sub
Many thanks Fluff.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,267
Members
448,558
Latest member
aivin

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