Pass Input box entry as Array

Shinpaj

New Member
Joined
Oct 3, 2012
Messages
2
I want to allow the user to enter the name of the worksheet that they want to print with the use of an INPUT BOX. The code below works for a single worksheet; however, I want to expand the number of worksheets the user can print, and I think I want to use an array to capture the various entries made by the user. For example, the bolded portion of the code passes the user input to a print function, so if the user enters Sheet1, the code will go to Sheet1, print it, then paste the next employee from the employee list and loops through until the active cell is empty. I want to allow the user to enter multiple worksheets, for instance, the user can enter Sheet1, Sheet2, Sheet3 and the code will print all three worksheets...

any advice? See code below:
Private Sub optionPrint_Click()
Dim sVar As String

'Make sure worksheet that contains the employee list is visible
Sheets("PrintList").Visible = True

'Specify sheet to print using input box...Store as variable sVar
sVar = InputBox("Enter name of sheet to print")

'Activate the first cell at the top of the employee list
Sheets("PrintList").Select
Range("A1").Select

'Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)

'Copy name to be pasted in drop_List
Selection.Copy

'Select worksheet where copy will be pasted
Sheets("OpsDash").Select

'Paste copy in dropdown list
Range("drop_List").Select
ActiveSheet.Paste

'Go to worksheet name that was entered into the input box
Sheets(sVar).Select

'Call to print function
Call cdPrint

'Go back to printlist worksheet and move active cell down one (1) with offset property
Sheets("PrintList").Select
ActiveCell.Offset(1, 0).Select

Loop

'Hide printlist worksheet
Sheets("PrintList").Visible = False

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
has nobody ever passed an array argument through an input box?
Can anyone help? It would be very much appreciated.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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