Printing multiple sheets from a macro

T

Taylor Francis

How do I print multiple sheets from a macro. I don't want to select
them individually and print them individually, but rather choose
multiple sheets and print them with one print call so they end up as one
print job...

Thanks
Taylor
 
R

Ron de Bruin

Try

Sheets(Array("Sheet1", "Sheet3")).PrintOut
'all sheets in the array

ActiveWindow.SelectedSheets.PrintOut
'print all selected sheets
 
T

Taylor Francis

I want to print the first sheet, and then the 3rd - end sheets, with no
set number of sheets...
do i need (how do i use) a dynamic array?
 
R

Ron de Bruin

Hi Taylor
Do I understand you correct that you want to print all sheets except the second sheet.
 
D

Dave Peterson

One way:

Option Explicit
Sub testme02()

Dim mySheetNames() As String
Dim wksCtr As Long
Dim iCtr As Long

ReDim mySheetNames(1 To Worksheets.Count - 1)

iCtr = 0
For wksCtr = 1 To Worksheets.Count
If wksCtr = 2 Then
'do nothing
Else
iCtr = iCtr + 1
mySheetNames(iCtr) = Worksheets(wksCtr).Name
End If
Next wksCtr

If iCtr = 0 Then
MsgBox "nothing selected"
Else
Worksheets(mySheetNames).PrintPreview '.printout
End If

End Sub
 
Top