PC Review


Reply
Thread Tools Rate Thread

Change Log with prior and new values

 
 
=?Utf-8?B?YnN0b2JhcnQ=?=
Guest
Posts: n/a
 
      25th Aug 2007
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.
 
Reply With Quote
 
 
 
 
Bill Renaud
Guest
Posts: n/a
 
      25th Aug 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding/omitting/all the values prior to todays date tleehh Microsoft Excel Worksheet Functions 2 9th Dec 2009 08:02 PM
Prior Values owilson Microsoft Access Queries 1 30th Jan 2005 01:02 AM
Adding values for prior date intervals =?Utf-8?B?UWFzcGVj?= Microsoft Excel Worksheet Functions 1 25th Jan 2005 01:49 AM
sum values between today and 6 months prior =?Utf-8?B?UWFzcGVj?= Microsoft Excel Worksheet Functions 3 19th Jan 2005 08:17 PM
all values prior to certain date =?Utf-8?B?Sk1vcnJlbGw=?= Microsoft Access Queries 3 25th Oct 2004 11:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:29 AM.