To save one Excel worksheet as a separate file with VBA, copy it to a new workbook with the worksheet’s Copy method, then save that workbook with SaveAs. The example below creates a one-sheet .xlsx file beside the original workbook; it leaves the source workbook open and unchanged.
What happens when VBA saves a worksheet as a file?
An Excel worksheet is not a standalone file. A workbook is the file, so the usual way to export a worksheet is to create a new workbook containing a copy of that sheet and save the new workbook. In VBA, calling Copy without specifying a destination creates a new workbook containing the copied worksheet.
This distinction matters: saving the new workbook writes only the copied sheet and any elements that come with it, rather than saving the entire source workbook. It is useful for sending a report, creating a periodic snapshot, or giving someone a clean workbook without the other tabs. The original sheet remains in its original workbook.
“Save a worksheet as a new file” can also mean saving the whole workbook under another name, exporting a sheet to PDF, or copying its values into a new file. Those are different tasks. For a real Excel workbook with a copied sheet, use worksheet copying followed by SaveAs.
VBA example: copy a sheet into a new .xlsx workbook
This macro expects a worksheet named Report in the workbook that contains the macro. It saves a timestamped .xlsx file in the same folder as that workbook, which helps avoid overwriting a previous export.
Sub SaveReportAsNewWorkbook()
Dim sourceSheet As Worksheet
Dim outputBook As Workbook
Dim folderPath As String
Dim outputPath As String
Dim fileName As String
Dim errorText As String
On Error GoTo SaveFailed
Set sourceSheet = ThisWorkbook.Worksheets("Report")
' The source workbook must already have a folder location.
If Len(ThisWorkbook.Path) = 0 Then
MsgBox "Save the source workbook before running this macro.", vbExclamation
Exit Sub
End If
folderPath = ThisWorkbook.Path
fileName = "Report_" & Format(Now, "yyyymmdd_hhnnss") & ".xlsx"
outputPath = folderPath & Application.PathSeparator & fileName
' Do not replace an existing file by accident.
If Len(Dir(outputPath)) > 0 Then
MsgBox "A file with that name already exists: " & outputPath, vbExclamation
Exit Sub
End If
sourceSheet.Copy
Set outputBook = ActiveWorkbook
outputBook.SaveAs Filename:=outputPath, FileFormat:=xlOpenXMLWorkbook
MsgBox "Created: " & outputPath, vbInformation
Exit Sub
SaveFailed:
errorText = Err.Description
On Error Resume Next
If Not outputBook Is Nothing Then outputBook.Close SaveChanges:=False
On Error GoTo 0
MsgBox "The worksheet could not be saved. " & errorText, vbCritical
End Sub
Change Report to the exact tab name, including spaces and punctuation. The Format pattern adds the date and time to the filename; for instance, a run at 2:35 p.m. on 6 November 2026 creates a name like Report_20261106_143500.xlsx. Application.PathSeparator supplies the appropriate folder separator for the operating system.
Before running any macro, save a separate copy of your workbook. VBA actions generally cannot be reversed with Ctrl+Z, even if a particular macro does not intentionally edit the original sheet.
How to add and run the macro
- In Excel for Microsoft 365 on Windows, save the source workbook, then press Alt+F11 to open the Visual Basic Editor. On Mac, use Tools > Macro > Visual Basic Editor; the available keyboard shortcut can vary by Mac keyboard and Excel settings.
- In the editor, select the workbook project, choose Insert > Module, and paste the code into the module. A standard module is a suitable place for this procedure.
- Return to Excel and run
SaveReportAsNewWorkbookfrom the Macros dialog, opened with Alt+F8 on Windows. On Mac, use Tools > Macro > Macros. - Check the message for the output location, then open the new file and verify its contents before sharing or moving it.
If the workbook is stored in a cloud-synced folder, the path shown by Excel may be a local synced path rather than a share link. Give collaborators the right file through the storage service, or change the macro to save to a location appropriate for your workflow.
Choose the right filename and file format
The sample uses xlOpenXMLWorkbook, Excel’s file format for an ordinary .xlsx workbook. That format is widely compatible and does not preserve VBA macros. A new workbook containing a copied worksheet is therefore a good fit for sharing data and report layouts when the exported file does not need to run macros.
If the copied worksheet includes worksheet-level VBA code, or the new workbook must contain VBA, use a macro-enabled format instead. The extension and format constant must agree: for example, use a filename ending in .xlsm and FileFormat:=xlOpenXMLWorkbookMacroEnabled. Do not just change the extension on an .xlsx file; that does not turn it into a macro-enabled workbook. Excel may also display a compatibility or macro-content warning depending on what the copied sheet contains.
The timestamped name reduces the chance of a collision, but it does not replace a deliberate naming policy. Consider whether exports should include a date, a report period, a customer or department identifier, and a version marker. Avoid characters Windows does not permit in filenames, such as a colon or a question mark. If names come from worksheet cells, clean and validate those values before using them in a path.
What gets copied—and what may not be self-contained
Copying a sheet typically carries its cell contents, formatting, formulas, and many worksheet-level items, such as charts and shapes, into the new workbook. The result can still depend on the source workbook, however. A sheet that refers to another tab may retain formulas that point back to the original file. For example, a formula that used a value on a different source sheet may become an external reference rather than a formula that works independently in the export.
This is a common surprise: a file can open successfully but show links to the original workbook, outdated values, or prompts to update links. Before distributing an export, inspect formulas and use Data > Workbook Links, where available, to review linked workbooks. Menu labels and link-management features can differ by Excel build. If the recipient needs a static report, consider replacing formulas with their displayed values in a copy, after checking that this is acceptable for the task.
Likewise, a copied sheet may rely on named ranges, data connections, PivotTable sources, or other workbook-level resources. Some dependencies may continue to work, while others can require the original workbook or a refresh. Test the exported file in the way the recipient will use it. If the goal is an independent deliverable, removing links or converting formulas to values may be necessary, but do that only in the exported copy and retain the original data where needed.
Save a copy of the whole workbook instead
Do not confuse worksheet copying with the workbook method SaveCopyAs. SaveCopyAs creates a copy of the entire workbook; it does not select one sheet or create a one-sheet workbook. It is appropriate when you want a backup or a duplicate of all tabs, formulas, and workbook structure.
For a single-sheet file, the key sequence is sourceSheet.Copy, capture the newly created workbook, then call that workbook’s SaveAs method. For a full-workbook duplicate, use a workbook-level copy or save operation instead. Choosing the correct object—worksheet or workbook—prevents the frequent mistake of producing a larger file than intended.
Manual method, Excel for Mac, and Excel for the web
For a one-off export, the interface may be simpler than a macro. In desktop Excel, right-click the worksheet tab, choose Move or Copy, select (new book) in the “To book” list, tick Create a copy, and choose OK. Then save the new workbook with File > Save As. If you leave the copy box unticked, Excel moves the sheet out of its original workbook instead of duplicating it, so check that option carefully.
Excel for Mac has worksheet copying and VBA support in desktop Excel, though some dialogs, shortcuts, and file paths differ from Windows. The example uses Application.PathSeparator rather than hard-coding a Windows backslash, but test any macro that writes to a location with special permissions or cloud storage. Excel for the web can open and edit many workbook files, but it cannot run VBA macros; use desktop Excel to run this code. For occasional copying in the web app, use the available sheet-copy interface or download and open the workbook in desktop Excel if that option is not available in your environment.
Common problems and safer troubleshooting
- “Subscript out of range”: The workbook does not contain a sheet with the exact name used in the code. Check spelling, spaces, and whether the tab is a worksheet rather than a chart sheet.
- The source workbook has no path: A new, unsaved workbook has an empty
ThisWorkbook.Path. Save it first so the macro has a folder in which to create the export. - The destination is unavailable: The folder may be read-only, disconnected, or restricted by permissions. Try a writable local folder or adjust the output path.
- The file already exists: The sample checks for an existing filename and stops rather than intentionally replacing it. Use a different naming scheme or remove the old export after confirming it is no longer needed.
- The export asks to update links: Review cross-sheet formulas and workbook links. A copied sheet is not automatically a values-only snapshot.
- The macro will not run: Confirm the file is saved in a macro-capable format, macros are allowed under your organization’s security settings, and you are using desktop Excel rather than Excel for the web.
For easier diagnosis, run the macro on a test copy and first try it with a small sample workbook. Avoid disabling Excel security prompts globally to make a macro run; follow your organization’s trusted-document and macro policies instead.
Frequently Asked Questions
Can VBA save only the active worksheet as a new workbook?
Yes. Set a worksheet variable to the active sheet, call its Copy method without a destination, and save the resulting active workbook. In a repeatable macro, naming the worksheet explicitly is safer than relying on whichever tab happens to be active.
Does copying a worksheet break links to other sheets?
Not necessarily. Formulas that refer to sheets outside the copied sheet can become references to the original workbook. Review the exported workbook’s formulas and links, and convert formulas to values in the copy if a static, independent report is required.
Can I save the copied sheet as CSV?
Yes, but CSV stores plain text data from a sheet rather than its Excel formatting, charts, formulas as formulas, or other workbook features. For a CSV export, create the one-sheet workbook and save it with the CSV file format and matching extension; confirm the intended delimiter and text encoding for the recipient.
Can the macro overwrite an existing export?
The example deliberately stops if its timestamped output path already exists. To support overwriting, you would need to change that check and decide how to handle Excel’s replacement confirmation. Keeping the stop behavior is safer when exports may be important.
Will the macro work in Excel for the web?
No. Excel for the web does not execute VBA. Run the macro in desktop Excel for Windows or Mac, or use the manual sheet-copy method available in your version of Excel.
Related
- Excel Solver in Google Sheets: Tools, Setup, and Limits
- Excel Solver Examples for Real Optimization Problems
- Excel Solver: Find Numbers That Sum to a Value?
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA Loop Over a Range: Methods, Examples, and TipsTo loop over cells in an Excel range with VBA, use For Each cell In someRange when you…
- VBA Select, Copy and Paste in Excel: Practical GuideIn Excel VBA, you can select a range, copy it, and paste it elsewhere, but most macros work…
- Excel VBA Reference: Where to Find It and How to Use ItAn Excel VBA reference can mean either Microsoft’s documentation for Excel’s VBA object model or a library that…
- Excel VBA: Find the Row Number of a Matching ValueIn Excel VBA, use the Range.Find method to locate a value, then read the matching cell’s .Row property.…
- VBA Copy and Paste to the Last Available RowTo copy data with VBA to the first available row after existing data, find the last occupied row…
- VBA Delete Whole Row: Safe Methods and ExamplesTo delete an entire worksheet row with VBA, use Rows(5).EntireRow.Delete, replacing 5 with the row number you want…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.