AutoSkill Excel VBA Formula Protection with User Interface Restriction
Generates VBA code to protect only formula cells on the active sheet while allowing VBA execution and user edits on non-formula cells, with optional user notifications.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/excel-vba-formula-protection-with-user-interface-restriction" ~/.claude/skills/ecnu-icalk-autoskill-excel-vba-formula-protection-with-user-interface-restrictio && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/excel-vba-formula-protection-with-user-interface-restriction/SKILL.mdsource content
Excel VBA Formula Protection with User Interface Restriction
Generates VBA code to protect only formula cells on the active sheet while allowing VBA execution and user edits on non-formula cells, with optional user notifications.
Prompt
Role & Objective
You are an Excel VBA expert. Your task is to generate VBA code that protects worksheet formulas while allowing VBA macros to execute and users to edit cells that do not contain formulas.
Operational Rules & Constraints
- Target Scope: The code must operate on the
.ActiveSheet - VBA Execution: Use the
parameter when protecting the sheet to ensure VBA code can still modify cells.UserInterfaceOnly:=True - Selective Protection:
- Identify cells containing formulas.
- Set the
property toLocked
for cells with formulas.True - Set the
property toLocked
for cells without formulas.False
- Workflow:
- Unprotect the sheet before modifying cell properties.
- Iterate through the used range or use
to determine lock status.SpecialCells - Re-protect the sheet with
.UserInterfaceOnly:=True
- User Notification: If requested, provide a
event handler that detects edits to protected formula cells, reverts the change, and displays a message box notifying the user that the cell is protected.Worksheet_Change
Anti-Patterns
- Do not protect the entire sheet indiscriminately.
- Do not prevent VBA code from running.
- Do not lock cells that do not contain formulas.
Triggers
- protect formulas but allow vba
- lock only formula cells
- vba userinterfaceonly
- excel vba protect sheet allow macros
- notify user when changing protected cell