How do I print multiple worksheets at the same time?
I should elaborate on my last post. This is a workbook that I have created
for users and I do not wish to require them to select worksheets prior to
printing. I want the command button to automatically print only the desired
worksheets. So far I can only get it to print the entire workbook. I have
tried the array printout method but keep encountering a runtime error.
"Otto Moehrbach" wrote:
Two ways to do this. The first way is to select the sheets you want
printed. You do this by the selecting the first sheet you want printed,
then hold down the Ctrl key and select the rest of the sheets you want
printed. Then run this macro:
Sub PrintAll
For Each sh In ActiveWindow.SelectedSheets
'Your print command here
Next
End Sub
The other way is to use a "For" loop through all the sheets and exclude the
ones you don't want printed. That macro looks like this:
Sub AllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name="ThisSht" Or ws.Name="ThatSht" Then GoTo NextSht
'Your print command here
NextSht:
Next ws
End Sub
HTH Otto
"jd1" wrote in message
...
I have added a command button into my spreadsheet which prints all sheets
at
once. However, I only want to print some of the worksheets. I only know
the
Visual Basic code (ActiveWorkbook.PrintOut) for the entire workbook. Can
anyone tell me the code to print only select worksheets? Thank you.
|