Create a new excel doc from 5 sheets in another doc

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

So I need a macro that can pull out (copy) 5 sheets from my excel document and create a new XLSM document

The sheets I want the use are

Data
Start
Report1
Report2
Report3

So I'd like to create this and save it to the same location as the current document, named whatever is in sheet"setup" cell G10

If possible I'd also like to make all formulas hidden
and sheet "Data" very hidden

please help if you can

Thanks

Tony
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi Tony,

Please note that you can only hide formulas when you protect the sheet as well. The following code should give you what you want.

VBA Code:
Option Explicit
Sub TonyWatsonHelp()    
    Dim FileName As String, wb As Workbook, sh As Worksheet
    FileName = ThisWorkbook.Sheets("setup").Range("G10").Value
    With ThisWorkbook.Sheets(Array("Data", "start", "Report1", "Report2", "Report3"))
        .Copy
    End With
    Set wb = ActiveWorkbook
    For Each sh In wb.Worksheets
        sh.UsedRange.SpecialCells(xlCellTypeFormulas).FormulaHidden = True
        sh.Protect Password:="123"  '<~~ Set your own password
    Next sh
    wb.Sheets("Data").Visible = xlVeryHidden
    wb.SaveAs ThisWorkbook.Path & "\" & FileName & ".xlsm", FileFormat:=52    
End Sub
 
Upvote 0
Hi Everyone,

So I need a macro that can pull out (copy) 5 sheets from my excel document and create a new XLSM document

The sheets I want the use are

Data
Start
Report1
Report2
Report3

So I'd like to create this and save it to the same location as the current document, named whatever is in sheet"setup" cell G10

If possible I'd also like to make all formulas hidden
and sheet "Data" very hidden

please help if you can

Thanks

Tony
Did you try the suggested code?
 
Upvote 0

Forum statistics

Threads
1,214,989
Messages
6,122,622
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top