Let's now see an example of how we can use theĪddress Property of the Range Object (Target) to only run code when a Note how we use the Address Property of the Range Object (Target) to MsgBox "You just changed " & Target.Address Target that we can use to determine exactly which cell has changed. The cell you land in after pushing Enter! It is the variable called Of the cell that was changed after pushing Enter. Private Sub Worksheet_Change(ByVal Target As Range) there is a Sheet* (Sheet*) would automatically add the Note, in Excel 97 accessing any the Module called Private Sub Worksheet_Change(ByVal Target As Range) Located in the top left of the module pane. Once here, you can select " Worksheet" from the Object drop down list,
Seen in the Project Explorer ( View> Project Explorer ( Ctrl+ R))
There are at least 2 ways to gain access to the private module of theġ) While in Excel proper, right click on the Worksheet name tab and chooseĢ) While in the VBE double click the Module called Sheet* (Sheet*), Worksheet Object and as such, the Worksheet_Change procedure MUST reside in the private module of theĪccessing the Private Module of the Worksheet Object The Worksheet_Change event is a procedure of the In Excel 97 Microsoft introduced what are called Events, one of these is the We can even specify which cell/cells must be The ability to automatically run/execute any Excel macro code of ourĬhoosing when data in any cell on a Worksheet changes. Excel VBA: Automatically Run Excel Macros When a Cell Changes/Enter Data.