How to Track Changed Excel Cells, Values, and Addresses with VBA
Question details
The user wants to programmatically track the addresses and new values of changed cells using VBA, particularly for integration with an add-in or backend application.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Developing a plug-in or macro that needs to securely log cell modifications (addresses and values) and send this data to a backend without relying on manual copy-pasting or conditional formatting.
- Observed behavior
- The user needs to capture modifications made by users, add-ins, or macros, storing the Target.Address and Target.Value while preventing the Worksheet_Change event from recursively calling itself.
Ensure you have the Developer tab enabled in your spreadsheet software and that your file is saved as a Macro-Enabled Workbook (.xlsm) to allow VBA scripts to run properly.
Use the Worksheet_Change Event to Log Cell Modifications
Add a VBA script to the worksheet module that triggers automatically whenever a cell is modified, safely logging its address and new value to a designated tracking sheet.
The Worksheet_Change event is triggered automatically when cells are edited. By capturing the 'Target' range parameter, you can extract both the exact address and the newly updated value.
It is crucial to temporarily disable events during the logging process. If your macro writes the logged data into the workbook without disabling events, it will trigger the Worksheet_Change event again, resulting in an infinite recursive loop.
Press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) editor.
In the Project Explorer pane on the left, locate your workbook and double-click the specific worksheet where you want to track changes (e.g., Sheet1).
Set up the event by entering 'Private Sub Worksheet_Change(ByVal Target As Range)'. Within this sub, define your logic to capture Target.Address and Target.Value.
Write the captured Target.Address and Target.Value to the next empty row on a separate sheet (e.g., Sheet2) so that you maintain a running log of all modifications.

Easily Manage VBA and Macros with WPS Spreadsheet
WPS Spreadsheet fully supports standard VBA macros, allowing you to seamlessly run Worksheet_Change events, track cell modifications, and integrate backend solutions just like in Microsoft Excel.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook in the Spreadsheet application.
- 2. Access the Developer Tab: Navigate to the Developer tab on the ribbon and click on the 'VBA Editor' icon (or press Alt + F11).
- 3. Input the tracking macro: Double-click your target sheet in the Project Explorer and paste your Worksheet_Change tracking code.
- 4. Save as a Macro-Enabled Workbook: Go to Menu > Save As, and choose 'Excel Macro-Enabled Workbook (*.xlsm)' to ensure your tracking functionality remains active.

Frequently Asked Questions
Why does my spreadsheet crash when running the Worksheet_Change event?
This usually happens due to a recursive call (an infinite loop). If your macro modifies a cell to log the data, that modification triggers the change event all over again. To fix this, add Application.EnableEvents = False at the start of your code and Application.EnableEvents = True at the end.
Does the Worksheet_SelectionChange event track modified cell values?
No, Worksheet_SelectionChange only triggers when you click or move your cursor to a different cell. To track actual data modifications and value updates, you must use the Worksheet_Change event.
Can I track changes made by other macros or add-ins?
Yes, the Worksheet_Change event will capture changes made by user inputs as well as standard macro or add-in operations, provided that macros are enabled and application events have not been explicitly turned off by those external scripts.
How do I capture the old value before the cell was changed?
Capturing the previous value requires using the Worksheet_SelectionChange event to temporarily store the cell's value in a global variable before it is edited. You can then reference that stored variable inside the Worksheet_Change event when the new value is committed.




