# print multiple sheets as one file

#### jjpkraft

##### New Member
I'm stumped and can't find any past message that work.

The worksheets to be printed are different each time. The user prints to fax so the print must be one file.

Here's what I thought would work but I get subscript out of range on the third last line:

Sub Print()
Dim strArray As String
strArray = Chr(34) & "Sheet2" & Chr(34)

If Sheets("Sheet3").Cells(2, 1).Value = "YES" Then
strArray = strArray & ", " & Chr(34) & "Sheet3" & Chr(34)
End If
If Sheets("Sheet4").Cells(2, 1).Value = "YES" Then
strArray = strArray & ", " & Chr(34) & "Sheet4" & Chr(34)
End If
If Sheets("Sheet5").Cells(2, 1).Value = "YES" Then
strArray = strArray & ", " & Chr(34) & "Sheet5" & Chr(34)
End If
If Sheets("Sheet6").Cells(2, 1).Value = "YES" Then
strArray = strArray & ", " & Chr(34) & "Sheet6" & Chr(34)
End If
If Sheets("Sheet7").Cells(2, 1).Value = "YES" Then
strArray = strArray & ", " & Chr(34) & "Sheet7" & Chr(34)
End If
Sheets(Array(strArray)).Select 'GET THE ERROR HERE
Sheets("Sheet2").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

I tried getting rid of the quotes around the end of the array and that doesn't work either.

Help!

### Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

#### jjpkraft

##### New Member
I already looked at that and don't see how it can help me. I looked again and still don't see it.

#### jjpkraft

##### New Member
Got it. it's always the easiest solution...sometimes it just takes some time to see it.

Sub Print()

If Sheets("Sheet3").Cells(2, 1).Value = "YES" Then
Sheets("Sheet3").select replace:=false
End If
If Sheets("Sheet4").Cells(2, 1).Value = "YES" Then
Sheets("Sheet4").select replace:=false
End If
If Sheets("Sheet5").Cells(2, 1).Value = "YES" Then
Sheets("Sheet5").select replace:=false
End If
If Sheets("Sheet6").Cells(2, 1).Value = "YES" Then
Sheets("Sheet6").select replace:=false
End If
If Sheets("Sheet7").Cells(2, 1).Value = "YES" Then
Sheets("Sheet7").select replace:=false
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

#### BuddieB

##### Board Regular
wow I never knew about that Replace:=false argument.

makes it much easier to select multiple sheets now.

thanks.

Replies
1
Views
235
Replies
1
Views
347
Replies
9
Views
238
Replies
9
Views
3K
Replies
8
Views
710

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,151,883
Messages
5,766,926
Members
425,386
Latest member
DougFarley

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

### Which adblocker are you using?

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

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