Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

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

0
Posted

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

0

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 I want Excel to run this macro automatically every time the Excel file is opened. Place the code in (or call it from) the Workbook_open event of the ThisWorkbook module in the VB editor. Or simply name your macro Auto_Open. If you choose to use both then Workbook__open will run before Auto_open. Auto_open will not run if the workbook is opened by another macro, you must use the RunAutoMacros method. Contrary; Workbook_open will run if the workboo

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123