ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a for selected sheets print named page macro (https://www.excelbanter.com/excel-programming/304655-selected-sheets-print-named-page-macro.html)

Todd

a for selected sheets print named page macro
 
Hi, I am working with a macro to print out all sheets in a workbook. I figure to group the sheets I want and then select which page to print. For example, I wish to print page 8 for every selected sheet.

My macro doesn't work. Did you know that already? Its pasted below, I get errors at the IF. Can anyone see the error and tell how to fix it?


Thanks,


Todd



Sub PrintSelectedSheets()
For Each sh In ActiveWindow.SelectedSheets
sh.Activate
x = InputBox("First Page to Print")
y = InputBox("Last Page to Print")
For Each ws In Worksheets
If ws.Index = Worksheets(x).Index
And ws.Index <= Worksheets(y).Index
Then ws.PrintOut From:=, To:=, Copies:=1, Collate :=True
End If
Next
Next
End Sub

JE McGimpsey

a for selected sheets print named page macro
 
If I understand you correctly:

Public Sub PrintSelectedSheets()
Dim sh As Worksheet
Dim x As Long
Dim y As Long
x = InputBox("First Page to Print")
y = InputBox("Last Page to Print")
For Each sh In ActiveWindow.SelectedSheets
sh.PrintOut _
From:=x, _
To:=y, _
Copies:=1, _
Collate:=True
Next sh
End Sub


In article ,
"Todd" wrote:

Hi, I am working with a macro to print out all sheets in a workbook. I
figure to group the sheets I want and then select which page to print. For
example, I wish to print page 8 for every selected sheet.

My macro doesn't work. Did you know that already? Its pasted below, I get
errors at the IF. Can anyone see the error and tell how to fix it?



All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com