ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   track cell changes (https://www.excelbanter.com/excel-programming/308601-track-cell-changes.html)

Caroline B

track cell changes
 
Is there a quick way to track/log changes made in a cell - there is an add-in
that calculates values (you can see the values in this cell) to produce other
values. I want to be able to list the values (as seen in this cell) - they
aren't logged or shown anywhere else by this add-in and are over written too
quickly to be noted down manually.

Tim Coddington

track cell changes
 
*** Warning Following example fails, but may give a good idea on how to do
it ***
Look at the following code that I wrote, attached to a worksheet:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
MsgBox "change"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
MsgBox "selection_change"
End Sub
The above shows events you can attach to the worksheet. Then each time you
move the
cursor in the worksheet in question, 'SelectionChange' fires. You could use
that event to
copy the value of the selection into a global.

Public Oldval As Variant
Public oldaddr As Variant

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not ActiveSheet.Name = "log" Then
Sheets("log").Select
Range("'log'!A1").End(xlDown).Offset(1, 0).Value = oldaddr
Range("'log'!A1").End(xlDown).Offset(1, 1).Value = Oldval
Range("'log'!A1").End(xlDown).Offset(1, 2).Value =
Range(oldaddr).Value
Sheets(1).Select
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Oldval = ActiveCell.Value
oldaddr = ActiveCell.Address
End Sub

The above code failes. Perhaps excel is too confused by trying to change
the
sheet before the event is done fireing. I don't know. But if you instead
of writing
changes to the 'log' sheet, if you used a flat file (opened with the open
statement)
you may have more success. You could then review the data in notepad or
bring
it into a spreadsheet.

"Caroline B" <Caroline wrote in message
...
Is there a quick way to track/log changes made in a cell - there is an

add-in
that calculates values (you can see the values in this cell) to produce

other
values. I want to be able to list the values (as seen in this cell) -

they
aren't logged or shown anywhere else by this add-in and are over written

too
quickly to be noted down manually.





All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com