Link to home
Start Free TrialLog in
Avatar of Matt Miller
Matt MillerFlag for United States of America

asked on

Trying to Copy sheets to a new workbook then hide sheets on original workbook

I'm trying to copy a group of sheets to a new workbook and then hide the initial sheets on the original workbook?'

      Sheets(Array("Read Me", "Sheet1", "Sheet2")). _
        Select

    Sheets(Array("Read Me", "Sheet1", "Sheet2")). _
        Copy
'Hide Readme

Open in new window


Thanks
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

To copy then hide all the originals, you could use:

    With Worksheets(Array("Read Me", "Sheet1", "Sheet2"))
        .Copy
        .Visible = xlSheetHidden
    End With

Open in new window

After copying to a new workbook, the new sheets will be active.

Therefore you will have to re-activate the source workbook to hide the original sheets.
@Rob
Not if you hold a reference to them, either with a With block, or a variable.
@Rory - didn't know that, everyday's a school day.
Otherwise, I would have suggested:

Source = ActiveWorkbook.Name
Sheets(Array("Read Me", "Sheet1", "Sheet2")).Select
Sheets(Array("Read Me", "Sheet1", "Sheet2")).Copy
Windows(Source).Activate
Sheets(Array("Read Me", "Sheet1", "Sheet2")).Visible = xlSheetHidden

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matt Miller

ASKER

Thank you very much.  This is exactly what I needed.
Pleased to help.