• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

Copy select Excel sheet from workbook to new workbook

I have a workbbok with many tabs.  I would like to have two of the tabs copied out to a new excel file which only contains these two sheets.  The two sheet I want to copy are called "data" and "report".  I want a new excel file that has these two sheets,  Can I do this through VBA?
  • 2
1 Solution
J NUnicorn wranglerCommented:
why dont you copy the old file and rename it and delete the tabs you dont want
marku24Author Commented:
I have over 25 tabs in the workbook.  Seems inefficient to do it that way.
here is a little code to get you started.

Public Sub MakeNew()
    Application.SheetsInNewWorkbook = 2
    Dim wbNew As Workbook
    Set wbNew = Workbooks.Add

    wbNew.Sheets(1).Name = "Data"
    wbNew.Sheets(2).Name = "Reports"
    ThisWorkbook.Sheets("Data").Cells.Copy wbNew.Sheets(1).Range("A1")
    ThisWorkbook.Sheets("Reports").Cells.Copy wbNew.Sheets(2).Range("A1")
    wbNew.Close True, "C:\Temp\NewWB.xlsx"
    Set wbNew = Nothing
End Sub
marku24Author Commented:
nicely done.  good starting point.  thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now