How do I keep a macro from running when I refresh a PivotTable in a separate worksheet? I right-clicked on the worksheet and added code to the worksheet itself, not the workbook. Yet every time I refresh a PivotTable in a SEPARATE worksheet, the macro runs. How do I stop this from happening? I want certain macros to run only when certian pivotTables are refreshed, change, etc.