I have a simple countif formula in Cell E2 that will check for a specific text. Once it's true, it'll execute a macro that will prompt for a msgbox. This code works fine, but when making any other changes to the worksheet will execute the macro again, even though Cell E2's value hasn't changed. How do I stop the macro from executing any further if E2 does not change at all?
Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("E2")) Is Nothing Then If Target.Value = "True" Then Application.EnableEvents = False a = MsgBox("Test", vbYesNo, "Test") If a = vbYes Then Range("E3") = "003" Else Range("E3") = "001" End If Call ApplyMG Application.EnableEvents = True End If End If End Sub EDIT: Thanks to the comment below, removed 'old code' setting target to the same range in the intersect line. However, the macro is not being triggered anymore.
Set Target = Range("E2")Application.EnableEvents = Trueand press enter, this should fix it for you.