Answers

Question and Answer:

  Home  MS Excel

⟩ How do I run a macro every time a certain cell changes its value?

There is an event called Worksheet_Change which is triggered when a value is entered (it will not fire when a formula result changes). One of the arguments to this event is 'Target' which is a reference to what changed. Since this event will occur whenever a value changes - you can use the target to see if it is the cell you are interested in:

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("C5")) Is Nothing Then

Exit Sub

Else

'The cell you are monitoring has changed!

'Do whatever you need to do...

End If

End Sub

 148 views

More Questions for you: