Reputation: 259
I want to write a VBA macro which triggers another macro after changing the value of a cell. This is what I came up with.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("n7")) Is Nothing Then Macro1
End Sub
However it doesn't work.
Upvotes: 2
Views: 41
Reputation: 33662
Try the code below, this code needs to be in the worksheet you are trying to modify cell "N7" and then call Macro1.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("N7")) Is Nothing Then Call Macro1
End Sub
Example of Sub Macro1
, located in another code module:
Sub Macro1()
MsgBox "Hello"
End Sub
Upvotes: 2