VBA: Worksheet Array

AngAgius

Board Regular
Joined
Feb 12, 2004
Messages
59
I'm using Array("Sheet1", "Sheet2", "Sheet3") to select a number of worksheets to copy to a new file to Print or create a PDF. Code works fine.

However, I would like the user to select which sheets to select for copy & print, this means the Array will vary in name & number selected. How can I do this? I've searched & searched but can't find it.

I'd appreciate if you could help me out, it's driving me nuts :)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Thanks VoG but that's not really my problem

How do I change Array("Sheet1", "Sheet2", "Sheet3") based on user input so for example if there is an additional worksheet the user requires so Array("Sheet1", "Sheet2", "Sheet3","Sheet4")..... n.b the sheets could be named as anything

The code copies the sheets to a new workbook, then range values, can either print or create PDF, saves the new workbook
 
Upvote 0
Sorry VoG, I should have been more clear.

There is a worksheet for Parameters.... it would be something like:

Input Worksheets to copy:
Sheet1
Sheet2
Sheet3
ect
 
Upvote 0
Maybe like this

Code:
With Worksheets("Parameters")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    mysheets = Application.Transpose(.Range("A1:A" & LR))
    Sheets(mysheets).Copy
End With
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

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