Arrays containing variable sheets

R

RichA

I am looking to be able to copy a number of sheets to a new workbook. However, these are not always the same sheets.


Sub Macro1()
Sheets(Array("SheetA", "SheetB")).Select
Sheets(Array("SheetA", "SheetB")).Copy
End Sub


How do I either:
(a) set the array to be the selected sheets prior to the macro being run? [I tried selectedsheets.select but it errored?]

(b) Creat an inputbox that allows an array of sheets (they are not always next to each other)?

Many thanks,
Rich
 
N

Norman Jones

I am looking to be able to copy a number of sheets to a new workbook. However, these are not always the same sheets.


Sub Macro1()
Sheets(Array("SheetA", "SheetB")).Select
Sheets(Array("SheetA", "SheetB")).Copy
End Sub


How do I either:
(a) set the array to be the selected sheets prior to the macro being run? [I tried selectedsheets.select but it errored?]

(b) Creat an inputbox that allows an array of sheets (they are not always next to each other)?

Many thanks,
Rich
Hi Rich,

Try:

ActiveWindow.SelectedSheets.Copy


===
Regards,
Norman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top