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
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