I have a code in which in one of its actions it assigns a value to C3. Once this code is complete, I have setup an event which would run a macro if C3 has changed in value.
Upon running this code, I found that once C3 has been assigned a value it would go through Worksheet_Change event and would run another macro there. This is not what I have intended.
Is there a way to assign a value C3 the first time without calling on Worksheet_Change event, while any subsequent changes in C3 would use the event?
Sub test
Cells(3, 3) = 10
End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim ValidateCode As Variant
On Error GoTo ErrHandler
Application.EnableEvents = False
If Target = Cells(3, 3) Then
ValidateCode = EntryIsValid(Target.Value) ‘ A check that is an integer
If ValidateCode = True Then
MacroCreateSheet ‘ << Call on a macro to perform an action if C3 is changed
Else
MsgBox ValidateCode, vbCritical, "Invalid Entry"
Target.ClearContents
Target.Activate
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub