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.


⧪ 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


<< Go Back to Track Changes | Share Workbook | Workbook in Excel | Learn Excel

What is ExcelDemy?

ExcelDemy - Learn Excel & Get Excel Solutions Center provides online Excel training , Excel consultancy services , free Excel tutorials, free support , and free Excel Templates for Excel professionals and businesses. Feel free to contact us with your Excel problems.
Rifat Hassan
Rifat Hassan

Rifat Hassan, BSc, Electrical and Electronic Engineering, Bangladesh University of Engineering and Technology, has worked with the ExcelDemy project for almost 2 years. Within these 2 years, he has written over 250 articles. He has also conducted a few Boot Camp sessions on effective coding, especially Visual Basic for Applications (VBA). Currently, he is working as a Software Developer to develop and deploy additional add-ins to enhance the customers with a more sophisticated experience with Microsoft Office Suits,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo