Pick a task from 50+ macros, set your sheet names, columns and ranges, and copy clean VBA with declared variables and an error handler — generated in your browser.
Excel VBA Macro Generator
Pick a task from 50+ macros, set your sheet names, columns and ranges, and copy clean VBA with declared variables and an error handler — generated in your browser.
Macros are generated entirely in your browser. The sheet names, ranges, paths and text you enter stay on your device and are never sent to ArrayKit.
Most Excel macros are variations on a small set of patterns: find the last row, loop without skipping rows, copy matches somewhere else, save a file. The Excel VBA Generator turns those patterns into forms. Choose a macro from the searchable library, fill in the sheet name, column letter, range or folder, and the code updates as you type. Every macro starts with Option Explicit, declares its variables, counts rows as Long, finds the last row with End(xlUp), avoids Select and Activate, and ends with an error handler that always switches screen updating, events and calculation back on. Macros that delete, overwrite, write files or create email carry a risk label and a reminder to test on a copy. Copy the code or download a .bas file; nothing you type is uploaded.
Features
More than 50 macros in seven groups: loops, clean-up, split and merge, files and email, sheets and layout, events, dialogs
Settings are validated: sheet names, column letters, ranges, names and numbers are checked before any code appears
Quotes and line breaks in your text are escaped so a value can never break the generated VBA
Option Explicit, declared variables, Long row counters and End(xlUp) last-row detection in every macro
Error handler that restores screen updating, events and calculation even when something fails
Risk labels and reminders for macros that delete data, write files or create email
Choose the procedure name, switch comments on or off, and work on this workbook or the active one
Copy the code or download a .bas file, with step-by-step instructions for pasting and saving as .xlsm
How to use the Excel VBA Macro Generator
Search or browse the library and pick the macro that matches your task
Fill in the settings — sheet name, column letter, range, folder or text — and fix anything flagged
Copy the code or download the .bas file
In Excel press Alt+F11, choose Insert > Module, paste, press F5, then save the file as .xlsm
Example
Input
Macro: Delete blank rows
Sheet: Orders
Blank means: every cell in the row is empty
First row to check: 2
Output
Public Sub DeleteBlankRows()
...
Set ws = ThisWorkbook.Worksheets("Orders")
lastRow = ws.UsedRange.Row + ws.UsedRange.Rows.Count - 1
For r = lastRow To 2 Step -1
If Application.WorksheetFunction.CountA(ws.Rows(r)) = 0 Then
ws.Rows(r).Delete
removed = removed + 1
End If
Next r
The loop runs bottom-up so deleting a row never makes the next one get skipped.
Common errors & troubleshooting
Pasting the code gives "Compile error: Variable not defined" or "Ambiguous name detected". — Paste the whole generated block into an empty module. When you combine several macros in one module, the small helper functions repeat — keep a single copy of each.
The macro does nothing, or Excel says macros are disabled. — Save the file as an Excel Macro-Enabled Workbook (.xlsm), then enable macros through File > Options > Trust Center. Only enable them in files you trust.
Run-time error 9: Subscript out of range. — The sheet name in the settings does not exist in the workbook the macro is working on. Check the spelling, and whether to work on this workbook or the active one.
A macro that deleted or overwrote data cannot be undone. — VBA changes bypass Ctrl+Z. Always run macros that delete, overwrite or write files on a copy of your workbook first.
Frequently asked questions
How does the Excel VBA Generator decide what code to produce?
Each macro in the library is a tested pattern with typed settings. Your values are validated and then placed into the code in the right spot, quoted where needed, so the output is ordinary VBA you can read, edit and reuse — there is no guessing involved.
Why does every generated macro include an error handler?
Macros that turn off screen updating or events leave Excel in a confusing state if they stop halfway. The handler switches those settings back on whatever happens, then shows the error number and description instead of a bare crash.
Do the generated macros use Select or Activate?
No. They work on worksheet and range objects directly, which is faster and does not depend on what is currently selected. Freezing panes is the one task Excel ties to the window, so that macro scrolls the view with Application.Goto instead of selecting a cell.
Can I use these macros on a Mac or in Excel for the web?
Most work in desktop Excel on Windows and many on a Mac, but VBA does not run in Excel for the web. The Outlook email macro needs Outlook for Windows, and file paths on a Mac use slashes instead of backslashes.
What is the difference between a .bas file and pasting the code?
A .bas file is a module you import with File > Import File in the VBA editor; pasting does the same by hand. Pasting is safer if your text contains accents or symbols, because a .bas file is read with the older ANSI character set.
Are my sheet names and file paths sent anywhere when I use the macro generator?
No. The settings and the code stay in your browser. Nothing is uploaded, and the generator only produces text for you to paste into Excel.
Related tools
Excel Formula Generator — Pick a task such as conditional sums, lookups, dates, text splitting or ranking and get a ready-to-paste Excel or Google Sheets formula.
Excel Formula Explainer — Paste any Excel or Google Sheets formula and get a plain-English, step-by-step breakdown of every function and argument.
Excel Data Cleaner — Clean messy spreadsheets: trim spaces, fix case, remove blanks and duplicates, standardise dates and numbers, then export .xlsx or CSV.
CSV to Excel Converter — Turn CSV or TSV files into a formatted .xlsx workbook in your browser: delimiter detection, header styling, column types and multiple sheets.
Excel to CSV — Convert an .xlsx or .xls spreadsheet to clean CSV or TSV, in your browser.
VLOOKUP Formula Generator — Build a correct VLOOKUP formula step by step, with IFERROR, exact or approximate match, XLOOKUP and INDEX MATCH alternatives and a live test.
INDEX MATCH Formula Generator — Generate INDEX MATCH formulas for left lookups, two-way lookups and multiple criteria, with a live test table and copy-ready output.
CSV to Excel Converter — Turn CSV or TSV files into a formatted .xlsx workbook in your browser: delimiter detection, header styling, column types and multiple sheets.
JSON to Excel Converter — Convert JSON arrays or nested objects into an Excel workbook with flattened columns, one sheet per array and typed cells.
Excel Data Cleaner — Clean messy spreadsheets: trim spaces, fix case, remove blanks and duplicates, standardise dates and numbers, then export .xlsx or CSV.
VLOOKUP Formula Generator — Build a correct VLOOKUP formula step by step, with IFERROR, exact or approximate match, XLOOKUP and INDEX MATCH alternatives and a live test.
INDEX MATCH Formula Generator — Generate INDEX MATCH formulas for left lookups, two-way lookups and multiple criteria, with a live test table and copy-ready output.
Excel Formula Explainer — Paste any Excel or Google Sheets formula and get a plain-English, step-by-step breakdown of every function and argument.
Excel Formula Generator — Pick a task such as conditional sums, lookups, dates, text splitting or ranking and get a ready-to-paste Excel or Google Sheets formula.
Excel Function Translator — Translate Excel formulas between English and German, French, Spanish, Italian, Portuguese, Dutch, Swedish and Russian, with correct separators.