vba script to add comments on cell change

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,583
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have written a macro that creates a new workbook. I would like the ability to track changes in this second workbook - put a comment with a timestamp. I am sure i saw a way of doing this. The new workbook is saved to the cloud. Can someone point me in the right direction ? thanks

kind regards
Kaps
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You could try something like this:

It will record the date of the change, the user who made the change and also copy a range so you can track what changes.

VBA Code:
Private Sub worksheet_change(ByVal target As Range)
If Not Intersect(target, Sheet11.Range("A2:M1000")) Is Nothing Then
lastrow = Sheet12.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row + 1

   Sheet12.Range("A" & lastrow).Value = Now
   Sheet12.Range("B" & lastrow).Value = Environ("UserName")
   Sheet12.Range("C" & lastrow & ":O" & lastrow).Value = Sheet11.Range("A" & target.Row & ":M" & target.Row).Value

End If
End Sub

...just change your sheets and ranges to match your needs.
 
Upvote 0

Forum statistics

Threads
1,215,078
Messages
6,122,996
Members
449,093
Latest member
masterms

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