I had the same Problem as in this post. The answer that was given, did what was asked, it executed code when a given cell is changed.
It also worked for me, except when I try to change the name of the Sub to anything else, the code stops being executed. No warning is given. Does anyone know why that is?
This is the code that was the solution to the previous question:
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Me.Range("D2")) Is Nothing Then Exit Sub Application.EnableEvents = False 'to prevent endless loop MsgBox "You changed THE CELL!" Application.EnableEvents = True End Sub or as a shorter Version
Private Sub Worksheet_Change(ByVal Target As Range) IF Target.Address = "$D$2" Then MsgBox("Cell D2 Has Changed.") End If End Sub Both Subs react the same way when I change their name. Is there a trigger somewhere that calls the macro, where I would have to also change the name?
Private Sub Worksheet_Change(ByVal Target As Range)is the event code that fires when theWorksheetobject is changed. If you change the name, then the code won't automatically fire when worksheet is changed.