You can copy a worksheet to a brand-new workbook in Excel VBA with a single line: ThisWorkbook.Worksheets("Sheet1").Copy. That creates a new workbook containing only that sheet. To control where it goes, use the Before or After argument with a workbook object, or use ActiveWorkbook after the copy. This guide walks through the exact code, the common pitfalls (formulas, macros, names, hidden sheets) and how to fix them.
What You'll Need
- Microsoft Excel (Windows or Mac) with the Developer tab enabled, or permission to run macros.
- A workbook saved as .xlsm (macro-enabled) if you want to keep the VBA code.
- Basic familiarity with the VBA Editor (Alt+F11 on Windows, Option+F11 on Mac).
Step-by-Step
- Open the workbook that contains the tab you want to copy.
- Press Alt+F11 (Windows) or Option+F11 (Mac) to open the VBA Editor. If the Developer tab is not visible, enable it via File > Options > Customize Ribbon and tick Developer.
- In the VBA Editor, insert a new module: Insert > Module.
- Paste the simplest version of the code into the module:
ReplaceSub CopyTabToNewWorkbook() ThisWorkbook.Worksheets("Sheet1").Copy End Sub"Sheet1"with the exact name of your tab (the name on the tab, not the code name). - Press F5 to run it. A new workbook appears containing a copy of that sheet. The new workbook is unsaved, so save it immediately with File > Save As.
- To place the copy into a specific new workbook rather than an automatic one, create the workbook first and copy before or after a sheet in it:
Adjust the path and file name.Sub CopyTabToSpecificWorkbook() Dim wbNew As Workbook Set wbNew = Workbooks.Add ThisWorkbook.Worksheets("Sheet1").Copy Before:=wbNew.Sheets(1) wbNew.SaveAs "C:\Temp\CopiedTab.xlsx" End SubWorkbooks.Addcreates a workbook with a default number of sheets; the copy is inserted before the first sheet. - If you want to copy the sheet and then remove the extra default sheets from the new workbook, loop through and delete them after the copy. Be careful: deleting sheets is permanent unless the workbook is unsaved.
- To copy multiple tabs at once, pass an array of sheet names:
This creates one new workbook containing both sheets in the order listed.ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Copy - Save and close the VBA Editor. Run the macro from Excel via Developer > Macros or assign it to a button.
Common Mistakes
- Using the code name instead of the tab name.
Worksheets("Sheet1")refers to the name shown on the tab. If you renamed the tab, use the new name. The code name (visible in the Properties window) is different. - Forgetting that
Copywithout arguments creates a new workbook. Many people expect it to copy within the same workbook. WithoutBeforeorAfter, it always creates a new workbook. - Losing formulas that reference other sheets. A copied sheet keeps formulas, but references to sheets not included in the copy will point to the original workbook or break. Check for
#REF!errors. - Macros in the copied sheet. Sheet-level event code (like
Worksheet_Change) is not copied to a new workbook unless you also export and import the code module. The new workbook will not carry the VBA project. - Hidden sheets.
Copyon a hidden sheet fails. Unhide it first or copy viaSheetscollection with the sheet visible. - Protected workbook structure. If the workbook structure is protected, copying may fail. Unprotect via Review > Protect Workbook.
Tips
- Use
ThisWorkbookto refer to the workbook containing the macro, andActiveWorkbookonly when you are sure which workbook is active. Mixing them is a common source of bugs. - After copying, the new workbook becomes the
ActiveWorkbook. Capture it in a variable immediately if you need to save or modify it. - To copy values only (no formulas), copy the sheet then use Paste Special, or loop through cells and assign
.Value. VBA does not have a one-line "copy sheet as values" command. - If the sheet contains a table or pivot table, the copy carries it, but pivot caches may need refreshing in the new workbook.
- Name the new file with a timestamp to avoid overwriting:
Format(Now, "yyyymmdd_hhmmss")in the file name.
Troubleshooting
If the macro errors with "Subscript out of range", the sheet name is wrong or the sheet is not in ThisWorkbook. Check the exact tab name, including spaces. If you get "Copy method of Worksheet class failed", the sheet may be hidden, the workbook structure protected, or Excel is in a state where a new workbook cannot be created (for example, a modal dialog is open). Close dialogs and try again. If the new workbook opens but formulas show errors, inspect references to other sheets and either include those sheets in the copy or convert formulas to values first. If the macro runs but nothing appears, check whether the new workbook opened behind the current window; use Alt+Tab or the View > Switch Windows menu. On Mac, some file path formats differ; use the Mac path style or Application.PathSeparator when building paths. If the code fails only on certain machines, check Trust Center settings: macros may be disabled, or the workbook may be in Protected View. Enable macros for that location via File > Options > Trust Center > Trust Center Settings > Macro Settings, and remove Protected View if the file came from the internet.
Frequently Asked Questions
Can I copy a tab to a new workbook without VBA?
Yes. Right-click the tab, choose Move or Copy, tick "Create a copy", and select "(new book)" from the To book dropdown. VBA is only needed for automation or repetition.
Does the copied sheet keep its formulas and formatting?
Yes, formulas, formatting, column widths, and most objects are copied. Formulas that reference sheets not included in the copy may break or point to the original workbook.
Why does my macro create a new workbook instead of copying within the same one?
Because Worksheet.Copy with no Before or After argument always creates a new workbook. To copy within the same workbook, use Copy Before:=Sheets(1) or After:=Sheets(Sheets.Count).
Can I copy a hidden sheet?
Not directly. Unhide it first (Worksheets("Name").Visible = xlSheetVisible), copy, then hide it again if needed.
Will the new workbook contain my VBA macros?
No. Sheet copies carry data and formatting, not the VBA project. You must export and import modules separately, and save the new file as .xlsm.
How do I copy a sheet and save it with a specific name?
After the copy, the new workbook is ActiveWorkbook. Use ActiveWorkbook.SaveAs "C:\Path\Name.xlsx". Ensure the path exists and the file is not open elsewhere.