Excel VBA’s ability to copy a sheet to a new workbook saves time and avoids manual duplication. Simply run this macro once, and your selected sheet will open in a new file instantly. No manual copying or saving steps needed—just assign it to a shortcut or run it from the Macros dialog.

What You'll Need

  • An Excel workbook with at least one sheet you want to copy.
  • Microsoft Excel installed on your PC or Mac.
  • Basic knowledge of VBA (Visual Basic for Applications) editor.
  • A new location to save the copied workbook (e.g., a folder on your desktop).

Step-by-Step

  1. Open the VBA Editor:
    1. Press Alt + F11 to open the VBA Editor. This opens the Project window where all your macros live.
    2. In the Project Explorer pane (left sidebar), double-click the workbook you want to modify (e.g., "Sheet1.xlsm" or "Workbook1.xlsx"). This will open the sheet's corresponding code module.
  2. Insert a New Macro:
    1. Go to the top menu bar and click Insert > Module. This adds a new code module where you can write your macro.
  3. Write the Macro Code:
    1. Replace any existing code with the following, replacing Sheet1 with the name of your sheet you want to copy:
    2.     Sub CopySheetToNewWorkbook()
              Dim newBook As Workbook
              On Error Resume Next
              Set newBook = Workbooks.Add
              With Workbooks("Sheet1") 'Change "Sheet1" to your sheet name
                  .Copy Destination:=newBook.Sheets(1)
              End With
              ActiveWorkbook.SaveAs Filename:="C:\YourFolder\CopiedSheet.xlsx", FileFormat:=xlExcel12
              MsgBox "Sheet copied successfully!", vbInformation
          End Sub
          
      1. Adjust the filename path (C:\YourFolder\CopiedSheet.xlsx) to match where you want to save the new workbook.
      2. If your sheet is named differently, change "Sheet1" to your actual sheet name.
  4. Run the Macro:
    1. Press F5 to run the macro. It will open a new workbook containing the copied sheet.
    2. If the macro runs but the new workbook doesn’t appear, check if Excel is blocking macros (go to File > Options > Trust Center > Trust Center Settings > Macro Settings and ensure macros are enabled).

Common Mistakes

  1. Error: "Object Required" or "Run-time error '1004': Application-defined or object-defined error
    1. This occurs if the sheet name isn’t correctly referenced. Double-check that "Sheet1" matches your sheet name exactly (no spaces or special characters).
    2. If Excel won’t find the sheet, try replacing "Sheet1" with ActiveSheet or ThisWorkbook.Sheets(1).
  2. Macro not executing
    1. Your file might be protected. Press Alt + F11, go to Tools > Macros, select the macro, and click Settings > Security to allow it.
    2. Check for typos in the code. Copy the code above exactly, as minor errors will break it.
  3. New workbook not saving
    1. The path might be incorrect. Replace "C:\YourFolder" with your actual folder path (e.g., "\\Server\Data\Sheets" for network folders).
    2. Ensure Excel has write permissions in the target folder.

Tips

  1. Modify the filename dynamically: Use variables to let users choose where to save the new workbook. Replace the hardcoded path with:
      Dim savePath As String
      savePath = InputBox("Enter save path: ", "New Workbook Location")
      If savePath <> "" Then
          newBook.SaveAs Filename:=savePath & "\CopiedSheet.xlsx", FileFormat:=xlExcel12
      End If
      
    This lets users specify the location interactively.
  2. Save as template: Add .xlsm to preserve macros, making it reusable. Example:
      newBook.SaveAs Filename:=savePath & "\CopiedSheetTemplate.xlsm", FileFormat:=xlWorkbookTemplate
      
  3. Bulk copy sheets: Use a loop to copy multiple sheets. Replace the code with:
      Sub CopyAllSheets()
          Dim ws As Worksheet, newBook As Workbook
          Set newBook = Workbooks.Add
          For Each ws In ThisWorkbook.Sheets
              ws.Copy Destination:=newBook.Sheets(ws.Name)
          Next ws
          newBook.SaveAs Filename:="C:\YourFolder\AllSheets.xlsx", FileFormat:=xlExcel12
      End Sub
      
  4. Shortcut for frequent use: After running the macro, right-click the Excel window > Macros > select CopySheetToNewWorkbook > Assign Macro > choose a keyboard shortcut (e.g., Ctrl+Shift+C).
  5. Error handling: Add this to catch issues gracefully:
      Sub SafeCopySheet()
          On Error GoTo ErrorHandler
          CopySheetToNewWorkbook
          Exit Sub
      ErrorHandler:
          MsgBox "Error: " & Err.Description & vbCrLf & Err.Number, vbCritical
      End Sub
      
    This shows detailed error messages instead of a blank screen.

Troubleshooting

  1. If the macro does not run at all:
    1. Restart Excel and try running the macro again.
    2. Check the Immediate Window (Alt + F11 > Tools > Windows > Immediate Window) to see if errors appear.
    3. Close and reopen the workbook containing the macro.
  2. If the new workbook opens but is empty:
    1. Verify the sheet name is correct. Use ThisWorkbook.Sheets("Sheet1") to avoid case sensitivity issues.
    2. Check if the sheet has hidden formatting. Try pasting the sheet into a new workbook manually first to confirm it works.
  3. If the file doesn’t save:
    1. Ensure the target folder is accessible. Test saving to a known location like the desktop.
    2. Check if Excel is in "Add-ins Only" mode (go to File > Options > Add-ins > Go > uncheck Enable all add-ins temporarily).
    3. Try running the macro in a fresh workbook to isolate the issue.
  4. If macros are greyed out in the VBA Editor:
    1. Go to Tools > Macros > Trust Macros in the macro manager.
    2. If Excel blocks macros by default, enable them in File > Options > Trust Center > Trust Center Settings > Macro Settings.

Frequently Asked Questions

How do I ensure the copied sheet retains formatting?

Add the following line before saving to preserve styles:

newBook.Sheets(1).Copy after:=Workbooks("Sheet1").Sheets(1)
newBook.SaveAs Filename:=savePath & "\CopiedSheet.xlsx", FileFormat:=xlExcel12, CreateBackup:=False
This ensures formatting is copied correctly.

Can I copy an entire workbook to a new workbook?

No, this macro only copies one sheet. To copy all sheets, use the loop example in the Tips section.

Why does my macro sometimes fail with "Run-time error '1004: Application-defined or object-defined error"?

This often happens due to incorrect sheet names or missing references. Use ThisWorkbook.Sheets("Sheet1") instead of just "Sheet1" for case-insensitive matching and ensure the sheet exists in the workbook.

How can I automatically save the new workbook to a network drive?

Replace the hardcoded path with:

newBook.SaveAs Filename:="\\Server\SharedFolder\Sheets\Copied_" & Format(Date, "yyyy-mm-dd") & ".xlsm", FileFormat:=xlWorkbookTemplate
This appends the date to the filename.

Will this macro work in Excel for Mac?

The basic macro code works on Mac with minor adjustments:

  • Use Ctrl + F5 instead of F5 to run the macro.
  • Replace \ with : in paths (e.g., C:/YourFolder).
  • Enable macros through Excel > Preferences > Security > Enable Macros.

How do I delete the original sheet after copying?

Modify the macro to delete the original sheet:

Sub CopySheetAndDeleteOriginal()
    Dim newBook As Workbook
    Set newBook = Workbooks.Add
    With ThisWorkbook.Sheets("Sheet1")
        .Copy Destination:=newBook.Sheets(1)
        .Delete
    End With
    newBook.SaveAs Filename:="C:\YourFolder\CopiedSheet.xlsx", FileFormat:=xlExcel12
End Sub
This removes the sheet from the original workbook after copying.