macro to select sheets/page in a workbook and print them

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I am trying to work out a macro to select both the sheets and the pages to print in a workbook. I want to have a dialog box open to select the sheets to be printed and the page on the sheet to print. I have started this macro but am not sure where to go now. I have the dialog boxes and the select sheets to print working but not the select pages. Can someone tell me how to get the dialog box to select pages working? Or any other mistakes I made so far? I am pretty new at this and what I have I "borrowed". :

Thanks

Tod

Sub PrintSelectedSheets(
x = InputBox("First Sheet to Print"
y = InputBox("Last Sheet to Print"
x = InputBox("First Page to Print"
y = InputBox("Last Page to Print"
For Each ws In Worksheet
If ws.Index >= Worksheets(x).Index And
ws.Index <= Worksheets(y).Index The
ws.PrintOut From:=5, To:=5, Copies:=1, Collate
:=Tru
End I
Nex
End Sub
 
Sub PrintSelectedSheets()
x = InputBox("First Sheet to Print")
y = InputBox("Last Sheet to Print")
z = InputBox("First Page to Print")
w = 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:=z, To:=w, Copies:=1, Collate _
:=True
End If
Next
End Sub

--

Vasant

Todd said:
Hi, I am trying to work out a macro to select both the sheets and the
pages to print in a workbook. I want to have a dialog box open to select
the sheets to be printed and the page on the sheet to print. I have started
this macro but am not sure where to go now. I have the dialog boxes and the
select sheets to print working but not the select pages. Can someone tell
me how to get the dialog box to select pages working? Or any other mistakes
I made so far? I am pretty new at this and what I have I "borrowed". :)
 
Back
Top