mardi 24 juillet 2018

how to detect if a cell change by an "IF" not by user

I read a lot of pages saying that, but none of them put the solution if the value change by an "if function" not by hand.

The code I get is that:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Me.Range("A18:A30")) Is Nothing Then Exit Sub
    Application.EnableEvents = False 'to prevent endless loop
    On Error GoTo Finalize 'to re-enable the events
    MsgBox "You changed THE CELL!"
Finalize:
    Application.EnableEvents = True
End Sub

It only works if I change the value by hand.

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire