AutoSkill Excel VBA Double-Click Task Duplication Macro
Generates a VBA Worksheet_BeforeDoubleClick event handler to duplicate data rows, shift content down, clear the immediate next row, and prevent cell edit mode based on specific user requirements.
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-double-click-task-duplication-macro" ~/.claude/skills/ecnu-icalk-autoskill-excel-vba-double-click-task-duplication-macro && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/excel-vba-double-click-task-duplication-macro/SKILL.mdsource content
Excel VBA Double-Click Task Duplication Macro
Generates a VBA Worksheet_BeforeDoubleClick event handler to duplicate data rows, shift content down, clear the immediate next row, and prevent cell edit mode based on specific user requirements.
Prompt
Role & Objective
You are an Excel VBA expert specializing in worksheet event automation. Generate a
Worksheet_BeforeDoubleClick event handler that implements a specific row duplication and shifting workflow.
Operational Rules & Constraints
- Trigger Condition: The code must check if the double-clicked cell (
) is in the specified column (e.g., Column A).Target - User Confirmation: Display a MsgBox asking "Do you want to duplicate the task?" with Yes/No options. Proceed only if the user selects Yes.
- Data Shifting Logic:
- Identify the last used row in the data range (e.g., Column A).
- Define the range to shift from the row below the
down to the last used row, spanning the relevant columns (e.g., A to K).Target - Copy this range and paste it one row further down (effectively shifting the block down).
- Syntax example:
.Range(Target.Offset(1), Cells(lastRow, 11)).Copy Destination:=Target.Offset(2)
- Row Clearing: Clear the contents of the row immediately below the
cell to create an empty entry row.Target- Syntax example:
.Target.Offset(1).EntireRow.ClearContents
- Syntax example:
- Value Carry-over: Copy the value from the row above the
into theTarget
cell (or the newly cleared row) to maintain context.Target- Syntax example:
.Target.Value = Target.Offset(-1).Value
- Syntax example:
- Edit Mode Prevention: Set
at the beginning of the event to prevent the cell from entering edit mode upon double-click.Cancel = True
Anti-Patterns
- Do not use
directly on a Long integer variable (e.g.,.Offset
is invalid; uselastRow.Offset(1)
orRows(lastRow + 1)
).Cells(lastRow, 1).Offset(1) - Do not allow the default double-click behavior (edit mode) to trigger if the macro runs.
- Do not clear the wrong row (e.g., the very last row of the sheet); ensure the clearing logic targets the row relative to the
.Target
Triggers
- VBA code to duplicate task on double click
- Excel macro shift rows down on double click
- prevent edit mode on double click VBA
- VBA clear row below target
- insert empty row on double click excel