Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Change Log with prior and new values

I'm in the process of creating a change log. The intention is to store any
change to any cell in the workbook, ideally including formatting changes.
Each time a cell is changed, both the old and new values should be stored.
I'm using the SheetChange workbook event. The challenge is to capture the
old value and format. I've tried two approaches:

1) Use of Undo to revert the Target to its previous value(s), capture those
values, then use Undo again to make the users change again. Here's a snippet
which should give you the idea:

' Revert to previous value(s), store that value, then switch back to
current value
Application.Undo ' Under the user's change
For Each cell In Target ' For each cell in the changed range
count = count + 1
' Precede formulas with "'", otherwise just take the .Formula value
If cell.HasFormula = False Then
logws.Cells(bottom + count, OldValCol) = cell.Formula
Else
logws.Cells(bottom + count, OldValCol) = "'" & cell.Formula
End If
Next
Application.Undo ' Redo the change that the user made.

This works, but when I tried to expand it to capture also the formatting by
using a Copy command between the two .Undo commands, I get an error. I
believe .Copy is interpreted as a user command, so the second Undo fails. So
my first question is whether there's a way to use Copy between the two
..Undos. A second question is whether there is another way to identify the
change after the SheetChange event, without usnig the two Undo commands at
all.

2) The second approach I tried was more elaborate. Whenever the
SelectionChange event fired I copied off the selection to a dummy sheet,
where it would be available for the SheetChange event to find it, if the user
made a change. This worked fairly well, but it became quite complicated.

Of course, if you happen to have a complete Change Log routine, I not too
proud to throw mine away and take someone else's. I do want both the old and
new value though. Just logging the new value would not be sufficient. On
this discussion board, the only change log I've been able to find stored only
the new value after a change.

Any ideas are welcome.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Change Log with prior and new values

Have you experimented with the "Tools|Track Changes" command? It tracks
changes to values by user and date, but does not track formatting
changes.

--
Regards,
Bill Renaud



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding/omitting/all the values prior to todays date tleehh Excel Worksheet Functions 2 December 9th 09 08:02 PM
Save value of cell prior to change Rick Excel Worksheet Functions 2 September 25th 09 06:22 PM
Validate all cell values against it's list prior to saving the she Hippy Excel Programming 2 January 16th 06 05:33 PM
Adding values for prior date intervals Qaspec Excel Worksheet Functions 0 January 25th 05 01:49 AM
sum values between today and 6 months prior Qaspec Excel Worksheet Functions 3 January 19th 05 08:17 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"