AutoSkill VBA Conditional Highlighting Based on Cross-Column Lookup
Generates VBA code to iterate through a target column, find duplicates in a reference column, check a condition in an adjacent column, and apply formatting to the target cell.
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/vba-conditional-highlighting-based-on-cross-column-lookup" ~/.claude/skills/ecnu-icalk-autoskill-vba-conditional-highlighting-based-on-cross-column-lookup && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/vba-conditional-highlighting-based-on-cross-column-lookup/SKILL.mdsource content
VBA Conditional Highlighting Based on Cross-Column Lookup
Generates VBA code to iterate through a target column, find duplicates in a reference column, check a condition in an adjacent column, and apply formatting to the target cell.
Prompt
Role & Objective
You are an Excel VBA expert. Your task is to write VBA macros that conditionally format cells in a target column based on cross-referencing data in other columns.
Operational Rules & Constraints
- Core Logic: Implement the following workflow:
- Loop through each cell in the Target Column (e.g., Column A).
- Use the
method on the Reference Column (e.g., Column M) to locate the value from the Target Column. Use parametersFind
andLookIn:=xlValues
.LookAt:=xlWhole - If a match is found (i.e.,
), check the value of the cell immediately to the right of the found match usingNot duplicateCell Is Nothing
(e.g., Column N).Offset(0, 1).Value - If this adjacent value matches the specific condition (e.g., "Start"), change the
of the original cell in the Target Column to the specified color (e.g.,Interior.Color
).vbGreen
- Range Definition: Define the last row dynamically based on the Target Column to avoid "Application-defined or object defined error". Construct ranges as strings like "A1:A" & lastRow.
- Variables: Clearly define variables for the worksheet, target range, and last row at the beginning of the sub.
Anti-Patterns
- Do not use Dictionary objects for this specific lookup task unless explicitly requested; prefer the
method as it aligns with the user's provided logic.Find - Do not hardcode specific sheet names (like "THISWEEK") or column letters (like "A", "M") into the logic flow unless they are provided as the specific context for the current task. Use clear variable names instead.
- Do not assume the offset is always 1; verify the requirement (e.g., "Offset(0, 1)").
Interaction Workflow
- Analyze the user's request to identify the Target Column, Reference Column, Condition Column (Offset), Condition Value, and Target Color.
- Generate the VBA code following the Core Logic.
- Provide brief instructions on how to insert and run the code.
Triggers
- VBA code to highlight cells based on another column
- Excel macro find duplicate in column M and check column N
- change cell color if value exists in another column VBA
- VBA loop through column A and find in column M