Run Macro if certain cell change

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
 
A

Anders S

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
 
R

Richard Daniels

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top