Automatically Run Macro when Cell Changes

Sometimes it is necessary to have a macro run when the contents of a specific cell changes.  The change in the cell could be typing something in or overwriting previous contents. To do this you will need to use some Excel VBA.

cell-changeWhat you need to do is go into the VBA environment of Excel. Normally we would create a new module to enter our code on to. But for this to work we need to have the code within the worksheet that the cell change will be occurring. So in my example it will be Sheet 1. Also, for this example, I will be referencing cell A1 to be the cell that has the changes.

Within the VBE for Excel double click Sheet1 under Microsoft Excel Objects on the left hand side. This will open a window on the right hand side. In that window enter the following code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then

Application.EnableEvents = False


Application.EnableEvents = True

End If

End Sub

For your version of this the parts to change are listed below.  Be sure to enter the macro within the correct worksheet otherwise this will not work.

If Target.Address = "$A$1" Then is referencing cell A1. Change this whatever cell you want.

Replace where it says 'ENTER YOUR MACRO HERE THAT WILL RUN WHEN CELL CHANGES with the code that you want to run when the cell changes.

Now go back to the worksheet. Whenever you make a change to cell A1, your macro should automatically run.

54 thoughts on “Automatically Run Macro when Cell Changes

  1. Lyle Reisser

    I do consider all the ideas you have introduced on your post. They’re really convincing and will certainly work. Still, the posts are very quick for starters. May you please lengthen them a little from next time? Thank you for the post.

Leave a Reply

Your email address will not be published. Required fields are marked *