print multiple sheets as one file

jjpkraft

New Member
Joined
Feb 26, 2002
Messages
32
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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I already looked at that and don't see how it can help me. I looked again and still don't see it.
 
Upvote 0
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
 
Upvote 0
wow I never knew about that Replace:=false argument.

makes it much easier to select multiple sheets now.

thanks.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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