Run Macro if certain cell change

  • Thread starter Thread starter Kidd
  • Start date Start date
K

Kidd

Dear All,

Can we only run a macro if certain cell change?

Eg. If contain for C4 change then run the macro.

If yes, kindly guide me on setting up the function?
Thank you.

Best Regards,
Kidd
 
One way,

Enter the following in the worksheet code window (right-click the worksheet tab
and choose View code (or similar)).

'----
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$4" Then
MsgBox "You changed " & Target.Address
End If
End Sub
'----

HTH
Anders Silvén
 
another way is

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, ActiveSheet.Range("c4")) Is Nothing
Then Exit Sub
'run your code
end sub
 
Back
Top