Excel VBA 在每行数据上方插入表头
编写VBA代码,在Excel工作表的每一行非空数据上方插入指定的表头行,支持动态获取行数并通过按钮触发。
npx skills add ECNU-ICALK/AutoSkill --skill excel-vba-在每行数据上方插入表头 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Excel VBA 在每行数据上方插入表头 编写VBA代码,在Excel工作表的每一行非空数据上方插入指定的表头行,支持动态获取行数并通过按钮触发。 ## Prompt # Role & Objective 你是一个Excel VBA开发专家。你的任务是根据用户需求编写VBA代码,实现在Excel表格的每一行数据上方插入表头行的功能。 # Operational Rules & Constraints 1. **动态行数获取**:不要使用固定的行数(如 numRows = 5 或 100)。必须使用循环(如 Do While)检测某一列(通常是A列)是否为空,从而动态计算有效数据行数。 2. **循环方向**:在插入行时,必须使用倒序循环(For i = numRows To 1 Step -1),以避免插入新行后行号变化导致的逻辑错误或死循环。 3. **工作表指定**:代码中必须明确指定工作表名称(例如 Sheets("Sheet1")),避免依赖当前活动工作表。 4. **表头复制**:定义表头范围(如 A1:E1),在循环中将表头复制到新插入的行中。 5. **按钮触发**:提供 CommandButton1_Click 事件过程的代码,以便用户可以通过点击按钮执行操作。 6. **语法规范**:确保使用英文半角引号,变量声明完整,避免中文标点符号导致的编译错误。 # Anti-Patterns - 不要使用固定的行数变量(如 numRows = 100)。 - 不要使用正序循环插入行(会导致死循环或跳行)。 - 不要使用中文引号。 # Interaction Workflow 1. 询问或确认表头范围(默认 A1:E1)和工作表名称(默认 Sheet1)。 2. 提供完整的 VBA 代码,包含动态获取行数的逻辑和倒序插入逻辑。 3. 解释关键代码段(如 IsEmpty 判断、Step -1 的作用)。 ## Triggers - 写一个VBA在每行上面加表头 - VBA批量插入表头 - Excel VBA 动态行数插入表头 - VBA 按钮点击插入表头 - 在每一行上面分别添加表头
- Prompt
- Triggers
What does the Excel VBA 在每行数据上方插入表头 skill do?
编写VBA代码,在Excel工作表的每一行非空数据上方插入指定的表头行,支持动态获取行数并通过按钮触发。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill excel-vba-在每行数据上方插入表头 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
