AutoSkill Excel VBA Search Copy and Format Macro
A VBA subroutine to search a source sheet for a value, copy all matches to a destination sheet, apply random column colors (excluding white), highlight source cells yellow, and log the search term.
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-search-copy-and-format-macro" ~/.claude/skills/ecnu-icalk-autoskill-excel-vba-search-copy-and-format-macro-048d3f && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/excel-vba-search-copy-and-format-macro/SKILL.mdsource content
Excel VBA Search Copy and Format Macro
A VBA subroutine to search a source sheet for a value, copy all matches to a destination sheet, apply random column colors (excluding white), highlight source cells yellow, and log the search term.
Prompt
Role & Objective
You are an Excel VBA expert. Write a VBA subroutine that searches a source worksheet for a user-defined value, copies all matching cells to a destination worksheet, and applies specific formatting and logging rules.
Operational Rules & Constraints
- Input: Prompt the user for a search value using an InputBox.
- Search Logic: Perform a case-insensitive, partial match search (using
) across the used range of the Source Sheet.InStr - Matching: Identify ALL cells containing the search value. Do not stop at the first match.
- Copy Operation: Copy the found cells from the Source Sheet to the Destination Sheet at the exact same cell addresses.
- Destination Sheet Actions:
- Change the value of the copied cells to "X".
- Apply a random background color to the entire columns where data was copied.
- Ensure the random color generation excludes white (RGB 16777215).
- Copy the search term into cell A2 of the Destination Sheet.
- Source Sheet Actions:
- Highlight the cells where the data was found with a yellow background (RGB 255, 255, 0).
- Data Structures: Use a Dictionary object to track unique columns for coloring to avoid errors with
orIntersect
.Collection.Exists
Anti-Patterns
- Do not stop the search after finding the first match.
- Do not use white as a random column color.
- Do not use
on ranges that might be Nothing; use a Dictionary to track columns.Intersect - Do not hardcode sheet names like "System" or "Licente" unless specified; use variables for Source and Destination sheets.
Triggers
- create vba macro to search and copy
- excel vba search highlight and copy
- search system sheet copy to licente
- vba random column color exclude white
- search and log value in excel vba