In Excel worksheet do the following :-
Private Sub Worksheet_Change(ByVal Target As Range)
- Click on the Developer tab.
- Click on the Visual Basic icon.
- On the left pane window, double click the sheet where you need your code to run.
- Now, at the top of the code window you will see... (General) with a drop down, and (Declarations) with a drop down.
- Click the drop down by (General) and select Worksheet.
- Now in the code window you will see.... Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Remove the word "Selection". You want to remove "Selection" because that means when you click on a cell in the worksheet something will happen. You do not want
- that, you want to enter a value in D10. It should now read...Private Sub Worksheet_Change(ByVal Target As Range)
- Now this is where you want the code...
If Target.Address = "$D$10" Then Call MyMacro End If End Sub