Recording the time changes are made in multiple cells

Joined
Nov 23, 2023
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi guys, I am experienced with vba, not so much with sheet events.
In a grid of cells, say A1:J10 a number of users might update single cells at a time. I plan to track the changes by using a procedure to update a sheet2 with Date+Time in the corresponding cell in the A1:J10 grid in sheet2. Do i need to run a separate event procedure for each cell, or can i use a single procedure ? Thanks 😊
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Open the vb editor. Double click on a sheet from the project objects pane on the left. If you pick one that already has code in it, you'll see that code. Regardless, in the top left drop down over the code page you'll probably see "General" - choose Worksheet instead. You'll probably see that it chooses an event and writes the opening and closing procedure lines. To me, that's a minor annoyance - let me pick fer cryin' out loud.

The right side drop down will list the worksheet events you can use. You'll want to use a sheet event for this - Change. If the changed cell is outside of the desired range, just exit the sub. I would just use Now() , not Date() and Time() as you seem to be suggesting, unless for some reason you need to split those portions.

EDIT - that does not apply if the changes are made by recalculating the sheet. For that you'd need the Calculate event - or both if changes can be made either way.
 
Last edited:
Upvote 0
For the good start, the procedure in the Sheet1 module. It is simple, although it is not without flaws.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Not Intersect(Target, Me.Range("A1:J10")) Is Nothing Then
        ThisWorkbook.Worksheets("Sheet2").Range(Target.Address).Value = Now
    End If
    
End Sub
Artik
 
Upvote 0
Solution
or, in case copy range (more than 1 cell) as one;

VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Intersect(Target, Range("A1:J10")) Is Nothing Then Exit Sub
For Each cell In Target
    With Sheets("Sheet2").Range(cell.Address)
        .Value = Now
        .EntireColumn.AutoFit
    End With
Next
End Sub
 
Upvote 0
Thank you guys for this. This is my first post here. I tried Artik's solution and its working perfectly. Didn't need to try bebo's solution. You guys are fantastic 👏
 
Upvote 0
Thank you Micron . I followed your instructions and used your suggested option of Now(). I may experiment with the Calculate event at some stage.

This advice has allowed me to run a standard vb script to send confirmation emails to their supervisors whenever up to 100 students complete up to 15 assignments.

I will happily accept a fish or a fishing pole...i had bought the Excel Professional Development book but my eyesight deteriorated so i can't read it clearly - do all my learning online now. Thanks again
 
Upvote 0
When my posts are long, I often ctrl+a to select all of it (unless that copies the entire page) and ctrl+c to copy just in case. Sometimes software does bad things to your posts. Too bad that happened because I'm the curious sort.
 
Upvote 0

Forum statistics

Threads
1,215,169
Messages
6,123,412
Members
449,098
Latest member
ArturS75

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