Write an Excel VBA macro from plain English

A ChatGPT prompt for Excel VBA macros — describe the task in plain English and get commented code, setup steps and safety checks.

Published
Works with
ChatGPT, Claude and Gemini
Level
Beginner
By
GoodAIPromt editorial team

Repetitive Excel work — copying data between sheets, formatting reports, splitting files — is a good fit for a VBA macro, but writing one from scratch is slow if you rarely code. This ChatGPT prompt for Excel VBA macros turns a plain-English description of your workbook and task into commented code, with steps to install it and checks so it does not damage your data.

The prompt

Act as an Excel VBA expert. Write a macro for this task.

What the macro should do, step by step: 
Workbook structure: sheet names, header row, columns and what they contain: 
Approximate number of rows: 
When it should run (button, on open, manually): 
Excel version: [VERSION, e.g. Microsoft 365 Windows / Mac]

Deliver:
1. Complete VBA code with Option Explicit, clear variable names and a comment on every block.
2. Error handling with a friendly message, and a check that the expected sheets and headers exist.
3. Performance settings (screen updating, calculation) that are restored at the end.
4. Step-by-step instructions to add the macro, save as .xlsm and assign it to a button.
5. How to test it safely on a copy of the file.
6. Settings I can change at the top of the code (sheet names, columns).
7. Limitations, and whether a formula, Power Query or Office Script would be a better choice.

0 of 4 blanks filled

How to use it

  1. Describe the columns exactly, including the header text, so the code finds the right data.
  2. Run it on a copy first; macros cannot be undone with Ctrl+Z.
  3. Paste any error message back with the line it stopped on to get a fix.

Tips

Frequently asked questions

What does this prompt do?

A ChatGPT prompt for Excel VBA macros — describe the task in plain English and get commented code, setup steps and safety checks.

Which AI tools does it work with?

It is written for ChatGPT, Claude and Gemini. It also works in other AI tools that accept text prompts, with small changes.

What do I need to fill in?

4 blanks: task in plain english; structure; rows; trigger. Click each blue blank on the page, type your details and press Copy prompt.

Is this prompt free to use?

Yes. You can copy and use it for personal and commercial work.

excel vbamacrosexcel automationspreadsheets

More prompts for ChatGPT, Claude, Gemini.