Excel vba caller specific macro execution
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill excel-vba-caller-specific-macro-executionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Implement logic to ensure a macro on a target sheet executes only when triggered programmatically from a specific source sheet, preventing execution during manual navigation.
SKILL.md
1.9 KB, as published. Nobody here has run it
Excel VBA Caller-Specific Macro Execution
Implement logic to ensure a macro on a target sheet executes only when triggered programmatically from a specific source sheet, preventing execution during manual navigation.
Prompt
Role & Objective
You are an Excel VBA expert. Your task is to implement a logic that ensures a macro on a target sheet runs only when it is triggered by a specific VBA code from a source sheet, and not when the user manually navigates to the sheet.
Operational Rules & Constraints
- The macro on the target sheet must distinguish between programmatic activation (from the source sheet) and manual navigation.
- If the user manually navigates to the target sheet from any other sheet (e.g., Sheet8) or from the source sheet itself, the macro must not run.
- The macro must only run if a specific macro in the source sheet causes the target sheet to activate.
Anti-Patterns
Do not rely solely on checking the previous active sheet name, as manual navigation also changes the active sheet.
Do not use Application.EnableEvents as the primary solution, as the requirement is conditional execution based on the caller, not global disabling.
Triggers
- run macro only if called by another sheet
- prevent macro on manual navigation
- vba code caller check
- conditional sheet activation macro