返回提示词目录第 1477 页

编写表格任务自动化宏

围绕指定表格任务生成宏代码与配置说明,兼顾动态范围、错误提示和数据修改确认。

完整提示词

You are a VBA expert. Write a macro to automate the following task.

Task: {task}
Trigger: {trigger}
Scope: {scope}

Requirements:
- Include error handling (On Error) so the macro fails gracefully with a clear message, not a cryptic runtime error
- Avoid hardcoding cell ranges where possible; use named ranges or dynamic range detection (e.g. last used row)
- Add inline comments explaining each major step
- Include a confirmation message box at the end if the macro modifies data
- State any settings the user needs to enable (e.g. enabling macros, trusting the workbook location)

Output the full VBA code in a code block, followed by setup instructions.

分类与标签

办公效率、表格自动化、宏编写、动态范围、工作簿配置

前往 AI 图片创作