Date and User stamp to show changes in a column that has linked Data from another Worksheet

Yeft

New Member
Joined
Jan 6, 2023
Messages
35
Office Version
  1. 365
Platform
  1. Windows
Could some one help me with a VBA code for showing Date and User name stamp when any change has been made to (Column A) of my table?
The VBA code I have works when typing in directly the new status in my table, but when Refreshing Data from a Query (Different Table), then new Columns get added
to the table and mess up with headers as well. I need to see all the stamps by just refreshing the Data:

Private Sub Worksheet_Change(ByVal Tgt As Range)

Dim MyData As Range
Dim MyDataRng As Range
Set MyDataRng = ActiveSheet.ListObjects("My Table").ListColumns(3).DataBodyRange

If Intersect(Tgt, MyDataRng) Is Nothing Then Exit Sub

On Error Resume Next
If Tgt.Offset(0, 1) = "" Then
Tgt.Offset(0, 1) = Now

Else
Tgt.Offset(0, 2) = Now
Tgt.Offset(0, 3) = Aplication.UserName


End If

For Each MyData In MyDataRng
If MyData = "" Then
MyData.Offset(0, 1).ClearContents
End If

Next MyData

End Sub
 

Attachments

  • My Table.jpg
    My Table.jpg
    42.1 KB · Views: 1

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
"Worksheet_Change" procedures are only fired when data is manually updated.
They are not fired when calculations run or values return by links or formulas change.

There is a "Worksheet_Calculate" procedure that fires whenever any calculation is run on a sheet, but the big caveat is that it cannot tell what value was updated or where.
So, you couldn't really use this to create a row-level date/time stamp.

So I don't think you are going to be able to simply "refresh" the data and get time stamps from the linked values that change.
The place to add the date stamps would be the source of the data, assuming those values are manually updated.
 
Upvote 0
"Worksheet_Change" procedures are only fired when data is manually updated.
They are not fired when calculations run or values return by links or formulas change.

There is a "Worksheet_Calculate" procedure that fires whenever any calculation is run on a sheet, but the big caveat is that it cannot tell what value was updated or where.
So, you couldn't really use this to create a row-level date/time stamp.

So I don't think you are going to be able to simply "refresh" the data and get time stamps from the linked values that change.
The place to add the date stamps would be the source of the data, assuming those values are manually updated.
Hello Joe4,
The source Data is a shared file via Teams, and Users open it and type changes that way. I tried to write the code, but unfortunately these shared files don't support macros.
I noticed that the code would work out only if people open the file as an App, but unfortunately there is no guarantee that people would do it, so changes done
directly from file via Teams won't update, so regardless the way they open the file I need to capture those stamps.
Please help me to figure this out regardless the way they open that file and enter that Data.
Thanks
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,005
Members
452,542
Latest member
Bricklin

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