Excel VBA: Track If a Cell Value Changes

Get FREE Advanced Excel Exercises with Solutions!

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

VBA Code to Track If a Cell Value Changes in Excel


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.

Opening the VBA Window to Track If a Cell Value Changes in Excel VBA


⧪ 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.

Opening Code Editor to Track If a Cell Value Changes in Excel VBA


⧪ 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

VBA Code to Track If a Cell Value Changes in Excel


⧪ 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.


Related Articles

Rifat Hassan
Rifat Hassan

Hello! Welcome to my profile. Here I will be posting articles related to Microsoft Excel. I am a passionate Electrical Engineer holding a Bachelor’s degree in Electrical and Electronic Engineering from the Bangladesh University of Engineering and Technology. Besides academic studies, I always love to keep pace with the revolution in technology that the world is rushing towards day by day. I am diligent, career-oriented, and ready to cherish knowledge throughout my life.

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo