Tracking log

gdspeare

Board Regular
Joined
Oct 8, 2002
Messages
198
I would like to create a sheet in my workbook that tracks the changes made to a certain cell. perhaps a log that will write the previous value in one cell and the new value in another. can you help?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
The only way I could think of would be to go to tools, Track Changes.

This will share your workbook and anyone editing including you will be tracked you can then have all the changes listed on a new worksheet. I hope this is of some use.

Thanks,

David_UK

:coffee:
 
Upvote 0
Insert a worksheet and name it Track. Put Old, New and When in cells A1, B1 and C1 respectively.

Activate the sheet whose changes you want to track, right click the sheet tab and choose View Code. Paste this code into the window on the right:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim NewVal As Variant
    Dim OldVal As Variant
    Dim Rng As Range
    If Target.Address <> "$A$1" Then Exit Sub
    Application.EnableEvents = False
    NewVal = Target.Value
    Application.Undo
    OldVal = Target.Value
    Target.Value = NewVal
    With Worksheets("Track")
        Set Rng = .Range("A65536").End(xlUp).Offset(1, 0)
        With Rng
            .Value = OldVal
            .Offset(0, 1).Value = NewVal
            .Offset(0, 2).Value = Now
            .Offset(0, 2).NumberFormat = "dd/mm/yy hh:mm:ss"
        End With
    End With
    Application.EnableEvents = True
End Sub

Change the reference to "$A$1" to the cell you want to monitor. Press Alt+F11 to return to your worksheet. Try it out by making some changes to the cell.
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

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