In this article, I’ll show you how you can track if a cell value changes in a worksheet using VBA in Excel.
Excel VBA: Track If a Cell Value Changes (Quick View)
Public Sub Worksheet_Change(ByVal target As Range)
MsgBox "The value changed in cell " & target.Address(0, 0)
End Sub
How to Track If a Cell Value Changes in Excel VBA: 5 Easy Steps
So, without further delay, let’s move to our main discussion today. We aim to develop a system using Excel VBA that’ll track all the cells in a worksheet and notify us if any cell changes. For your better understanding, I’ve divided the whole process into a number of steps.
Let’s go to the step-by-step analysis of the whole process.
⧪ Step 1: Opening the Visual Basic Window
Press ALT + F11 on your keyboard to open the Visual Basic window.
⧪ Step 2: Opening the Code Editor of the Particular Worksheet
In the left panel of the Visual Basic window, you’ll get a VBA project that consists of all the worksheets of the active workbook. Right-click on the worksheet that you want to trach, and select View Code.
Here, I’ve right-clicked on Sheet1.
⧪ Step 3: Entering Code into the Editor
Now, it’s the time for the code. Put this VBA code into the editor.
⧭ VBA Code:
Public Sub Worksheet_Change(ByVal target As Range)
MsgBox "The value changed in cell " & target.Address(0, 0)
End Sub
⧪ Step 4: Saving the File as Excel Macro-Enabled Workbook
Next, save the file as Excel Macro-Enabled Workbook.
Read More: How to Use Formula to Track Cell Changes in Excel
⧪ Step 5: The Output
Your worksheet is now ready to track. If you change the value of any cell in the worksheet, a message box will appear notifying you that the value in that cell has been changed.
Here I’ve changed the value in cell B4, and a message box is showing “The value changed in cell B4.”
Read More: How to See Who Made Changes in Excel
Things to Remember
Here I’ve used a message box to notify any change in the worksheet. But you notify it any other way, according to your wish. For example, you can call a Macro to run, or change the color of a particular cell, or anything.
Download Practice Workbook
Download this practice workbook to exercise while you are reading this article.
Conclusion
Therefore, this is the way to track if a cell value changes using VBA in Excel. Do you have any questions? Feel free to ask us.