Back to guide/General Productivity

VBA Macro Writer

Step-by-step workflow descriptions produce accurate macros. Requiring error handling prevents macros that crash silently. The paste-ready format instruction saves setup time.

chatgpt-prompts-for-exceldescribe_the_automationsheet_namesrange
Edit View
Prompt
Write a VBA macro for Excel that does the following:

**Task:** {{describe_the_automation}}
**Sheet(s) involved:** {{sheet_names}}
**Range:** {{range}} (e.g., "A1:D500" or "Column A, all rows with data")
**Trigger:** {{trigger}} (e.g., "button click", "workbook open", "cell change")

Step-by-step workflow:
1. {{step_1}}
2. {{step_2}}
3. {{step_3}}

Requirements:
- Include error handling (On Error GoTo)
- Add comments explaining each section
- Show a message box when complete with a summary
- Handle the case where the sheet or range is empty

Format the code so I can paste it directly into the VBA editor (Alt+F11 > Insert > Module).

Variables to customize

{{describe_the_automation}}{{sheet_names}}{{range}}{{trigger}}{{step_1}}{{step_2}}{{step_3}}

Why this prompt works

Step-by-step workflow descriptions produce accurate macros. Requiring error handling prevents macros that crash silently. The paste-ready format instruction saves setup time.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.