Initialize macro

  • Thread starter Thread starter Tom Jung
  • Start date Start date
T

Tom Jung

How do I initialize a macro to run when a cell value changes, the targe
cell contains a reference formula, with either a "0" or "1" as th
result, IU want the macro to start when the result is "1"
 
Hi Tom,

Try:
'============>>
Private Sub Worksheet_Calculate()
If Range("A1") = 1 Then
Call MyMacro
End If
End Sub

'<<============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

*******************************************
Right-click the worksheet's tab

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
*******************************************
 
What if I want to start the macro just by changing a letter in the cell, such
as Y or N?
 

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

Back
Top