Change Event - Track Multiple cell value changes

MHamid

Active Member
Joined
Jan 31, 2013
Messages
472
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I’m looking for some guidance so I can start writing my code.

I need to keep track of changes made in a worksheet ("Main") and placed into a "Log" Sheet. So let’s say that the cell values changed in range B7:F7;H7:I7 (or at least 1 of these cell value changes, then I want the previous values copied to a log sheet into range E3:K3 and the new value copied into range L3:R3.
The changes are based on formulas, if that makes a difference. So we will add new data weekly into another sheet, and the formulas in the Main Sheet will update automatically. I would like to see these changes reflected into a log sheet.
How can I accomplish this?
Below is the sample data.


Thank you,



TrackChangesSample.xlsx
ABCDEFGHI
6Account NumberOwnershipOwnership1Ownership2LocationImpactsNotationLocationRevisedSection
7159486OwnedBusiness1SubBusiness 1North AmericaSubBusiness2Based on blah blah blahNorth AmericaEH
84895OwnedBusiness2SubBusiness 4North AmericaSubBusiness3Based on blah blah blahAsiaWHO
915563Not OwnedNot Owned Business1Not Owned SubBusiness 1Based on blah blah blahEuropeTEST
104487952Not OwnedNot Owned Business1Not Owned SubBusiness 1Based on blah blah blahLatin AmericaBLAH
114522489Not OwnedNot Owned Business2Not Owned SubBusiness 2Not Owned SubBusiness 3Based on blah blah blahNorth AmericaWHAT
Main


TrackChangesSample.xlsx
ABCDEFGHIJKLMNOPQR
1PRIOR DATA / OLD DATANEW DATA / UPDATED DATA
2Week ofWeek ofCurrent DateAccount NumberOwnershipOwnership1Ownership2LocationImpactsLocationRevisedSectionOwnershipOwnership1Ownership2LocationImpactsLocationRevisedSection
35/23/20235/23/20235/27/2023159486OwnedBusiness1SubBusiness 1North AmericaSubBusiness2North AmericaEHNot OwnedNot Owned Business1Not Owned SubBusiness 1EuropeTEST
45/23/20235/23/20235/27/20234895OwnedBusiness2SubBusiness 4North AmericaSubBusiness3AsiaWHONot OwnedNot Owned Business2Not Owned SubBusiness 2Not Owned SubBusiness 3North AmericaWHAT
55/23/20235/23/20235/27/202315563Not OwnedNot Owned Business1Not Owned SubBusiness 1EuropeTESTOwnedBusiness2SubBusiness 4North AmericaSubBusiness3AsiaWHO
65/23/20235/23/20235/27/20234487952Not OwnedNot Owned Business1Not Owned SubBusiness 1Latin AmericaBLAHOwnedBusiness1SubBusiness 1North AmericaSubBusiness2North AmericaEH
75/23/20235/23/20235/27/20234522489Not OwnedNot Owned Business2Not Owned SubBusiness 2Not Owned SubBusiness 3North AmericaWHATOwnedBusiness1SubBusiness 1North AmericaSubBusiness2North AmericaBLAH
Log
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You will need to capture the change event in the sheet where the user makes the changes, not in the 'Main' sheet. This is because when the values of the formulas change, these are not seen as change events.

Personally I would do it as follows
  1. Create a Worksheet_Change() event for the sheet(s) where the users make changes
  2. the event should check if the change is in an area where it affects the main sheet (if that is relevant)
  3. if the change does affect the Main sheet, then store the changed value that the user made
  4. do an Application.Undo to undo this change
  5. Load the total table on the Main sheet into an array
  6. Redo the change by placing back the stored value
  7. Load the total table in Main again into another array
  8. Compare the two arrays and where they differ, store the value in the first array into your log sheet

An alternative method would be to store the Main table into an array on opening the Workbook, Then again track the changes of the usersheet and after each change:
  1. Load the Main table into the 2nd array
  2. Compare the two arrays and log changes as above
  3. then refresh the 1st array by loading the Main table again
The latter approach may be minimally more efficient, but the 1st array must be declared at the top of the ThisWorkbook module in order that it keeps its values
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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