Free VBA Code Generator for Excel Macros

Describe the macro you need in plain English. MySheetAI writes the VBA code and explains what it does. Free to use, no account required.

What is VBA?

VBA (Visual Basic for Applications) is the programming language built into Excel for automating repetitive tasks. A saved sequence of steps written in VBA is called a macro; once you have one, Excel can run it on demand instead of you repeating the same clicks every time.

How to run the generated macro

  1. 1

    Describe the macro

    Describe what you want the macro to do in plain English, for example the task, the sheet or columns involved, and any condition.

  2. 2

    Generate the code

    Click Generate macro. MySheetAI writes a VBA Sub procedure plus a plain-English explanation of what it does.

  3. 3

    Open the VBA editor

    In Excel, press Alt+F11 (or Option+F11 on a Mac) to open the Visual Basic editor.

  4. 4

    Add a module

    In the VBA editor, right-click your workbook in the Project pane, choose Insert, then Module.

  5. 5

    Paste and run

    Paste the generated code into the module, then press F5, or place your cursor in the Sub and press F5, to run it.

Example prompts

  • Loop through column A and delete every row where column B is blank.
  • Highlight every cell in column C that is greater than 1000 with a yellow fill.
  • Copy the active sheet to a new workbook and save it with today's date in the file name.
  • Remove duplicate rows based on the values in columns A and B.

Common questions

What is VBA?

VBA (Visual Basic for Applications) is the programming language built into Excel for automating repetitive tasks, called macros. A macro is a saved sequence of steps, written as VBA code, that Excel can run on demand.

How do I run a VBA macro in Excel?

Press Alt+F11 to open the VBA editor, right-click your workbook and choose Insert then Module, paste the code into the module, then press F5 (or click inside the Sub and press F5) to run it.

Do I need to enable macros to use generated VBA code?

Yes. Save your workbook as a macro-enabled file (.xlsm) and allow macros to run when Excel prompts you, or enable them under File > Options > Trust Center > Trust Center Settings > Macro Settings.

Is the VBA generator free?

Yes. Describing a task and generating the macro code is free and does not require an account.