You add a new worksheet in VBA with the Worksheets.Add method. The shortest working line is Worksheets.Add, which inserts a blank sheet before the active sheet and makes it the new active sheet. To control where it goes, what it is called, and how many copies you get, you pass arguments or set properties immediately after. This guide covers the exact syntax, the common variations (before/after a specific sheet, renaming, adding several at once, adding from another workbook), and the errors that trip people up.

What You'll Need

  • Excel on Windows or Mac with macros enabled (the Developer tab visible, or the ability to open the VBA editor with Alt+F11 on Windows, or Option+F11 on Mac).
  • A workbook saved as .xlsm (macro-enabled) if you want the code to persist. A plain .xlsx will drop the macro on save.
  • Basic familiarity with the VBA editor: inserting a module (Insert > Module) and running code with F5.

Menu labels in the VBA editor and Excel ribbon can differ slightly by version and by platform, so if a label does not match exactly, look for the closest equivalent.

Step-by-Step

  1. Open the VBA editor. Press Alt+F11 (Windows) or Option+F11 (Mac). The editor opens in a separate window.
  2. Insert a standard module. In the editor, choose Insert > Module. A blank code pane appears. Code placed in a sheet module or ThisWorkbook also runs, but a standard module keeps things tidy and lets you call the macro from the Macros dialog.
  3. Write the simplest version first. Type this into the module:
    Sub AddOneSheet()
        Worksheets.Add
    End Sub
    This inserts one new worksheet before the currently active sheet and selects it.
  4. Control the position. Use the Before or After argument to place the sheet relative to an existing one. You can pass a sheet name, a sheet index, or a worksheet object:
    Sub AddAtEnd()
        Worksheets.Add After:=Worksheets(Worksheets.Count)
    End Sub
    
    Sub AddBeforeSummary()
        Worksheets.Add Before:=Worksheets("Summary")
    End Sub
    Worksheets(Worksheets.Count) refers to the last sheet in the workbook, so adding after it puts the new sheet at the end. If the workbook has only one sheet, Worksheets.Count is 1 and the new sheet goes after sheet 1.
  5. Name the new sheet in the same statement. Assign the Name property of the object returned by Add:
    Sub AddNamedSheet()
        Dim ws As Worksheet
        Set ws = Worksheets.Add(After:=Worksheets(Worksheets.Count))
        ws.Name = "Report"
    End Sub
    Sheet names must be 31 characters or fewer and cannot contain : \ / ? * [ ]. They also cannot duplicate an existing name in the same workbook.
  6. Add several sheets at once. Pass a Count argument:
    Sub AddThreeSheets()
        Worksheets.Add Count:=3, After:=Worksheets(Worksheets.Count)
    End Sub
    The three new sheets are inserted together and the first of them becomes active. Note that Count must be at least 1.
  7. Add a sheet from another workbook. Use the Type argument with a path, or copy an existing sheet. Copying is usually safer because it preserves formatting:
    Sub CopySheetFromAnotherWorkbook()
        Workbooks("Source.xlsx").Worksheets("Template").Copy _
            After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
    End Sub
    This creates a copy in the workbook running the code. The source workbook must be open.
  8. Run the macro. Press F5 with the cursor inside the subroutine, or go back to Excel and use Developer > Macros, select the macro, and click Run. On Mac, the Developer tab may need to be enabled in Excel preferences first.
  9. Save as macro-enabled. Use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm). If you save as .xlsx, Excel warns that the macro will be removed.

Common Mistakes

  • Forgetting Set when assigning the new sheet to a variable. ws = Worksheets.Add fails; it must be Set ws = Worksheets.Add.
  • Using a duplicate name. Assigning a name that already exists raises run-time error 1004. Check with a loop or handle the error before assigning.
  • Assuming the new sheet goes at the end. With no arguments, Add inserts before the active sheet, not at the end. If the user is on sheet 1, the new sheet becomes sheet 1 and everything shifts right.
  • Naming a sheet with invalid characters. Colons, slashes, question marks, asterisks, square brackets, and names over 31 characters all fail.
  • Saving as .xlsx. The macro disappears on save and the workbook opens with no code next time.
  • Running code from a sheet module by accident. If the code is pasted into a worksheet's code pane, it may not appear in the Macros dialog. Move it to a standard module.

Tips

  • Use ThisWorkbook.Worksheets.Add instead of bare Worksheets.Add when the code might run while a different workbook is active. Bare Worksheets refers to the active workbook, which can surprise you if the user clicks elsewhere mid-run.
  • Store the new sheet in a variable so you can set multiple properties in one go: name, tab colour, and starting content.
  • To add a chart sheet rather than a worksheet, use Charts.Add. The syntax mirrors Worksheets.Add.
  • If you need a sheet that does not already exist, test first: On Error Resume Next around a lookup, or loop through Worksheets comparing names, then add only if missing.
  • Turn off ScreenUpdating while adding many sheets in a loop, then turn it back on, to keep the screen from flickering.

Troubleshooting

Run-time error 1004 "That name is already taken." The name you assigned matches an existing sheet or contains invalid characters. Pick a different name and re-run.

Run-time error 9 "Subscript out of range." You referred to a sheet name that does not exist in the active workbook. Check spelling and confirm which workbook the code is pointed at. Using ThisWorkbook avoids this when multiple workbooks are open.

The macro does not appear in the Macros list. The code is probably in a sheet module or the workbook is not macro-enabled. Move the code to a standard module and save as .xlsm.

Nothing happens when you run it. Check that macros are enabled in Trust Center settings, and that the subroutine is not marked Private if you are running it from the Macros dialog.

The new sheet appears in the wrong place. You omitted Before or After. Add After:=Worksheets(Worksheets.Count) to force it to the end.

If that did not work, close and reopen the workbook, confirm you are editing the correct file, and step through the code with F8 to see exactly which line fails.

Frequently Asked Questions

How do I add a worksheet at the end of the workbook?

Use Worksheets.Add After:=Worksheets(Worksheets.Count). This places the new sheet after the last existing sheet regardless of which sheet is active.

Can I add a sheet without activating it?

Yes. The Add method always activates the new sheet, so to keep the user on their current sheet, record the active sheet first, add the new one, then reactivate the original with original.Activate.

How do I name a new sheet in the same line?

You cannot name it inline; you must assign the Name property after the sheet exists, for example Set ws = Worksheets.Add: ws.Name = "Data".

Why does my code add the sheet to the wrong workbook?

Bare Worksheets refers to the active workbook. Qualify it with ThisWorkbook or a specific workbook variable to control which file receives the new sheet.

Can I add a sheet with a specific tab colour?

Yes. After adding, set ws.Tab.Color = RGB(0, 112, 192) or use a named colour constant. Tab colour is a property of the sheet object, not an argument of Add.

Does this work on Excel for Mac?

Yes, the VBA object model for worksheets is the same. The keyboard shortcut to open the editor differs (Option+F11), and the Developer tab may need to be enabled in preferences first.