Select for printing
This should work. Paste this code in a standard module. James
Sub PrintEm()
Dim k As Long, Ct As Integer
Dim Pg As Integer, BtmRow As Long
Dim ShtNm As String
With ThisWorkbook.Worksheets("Sheet1")
BtmRow = .Cells(.Rows.Count, "a").End(xlUp).Row
Ct = WorksheetFunction.CountIf(Range("b2:b" & BtmRow), "Y")
Pg = 1
For k = 2 To BtmRow
If .Cells(k, "b") = "Y" Then
ShtNm = .Cells(k, "a")
Worksheets(ShtNm).Activate
ActiveSheet.PageSetup.RightFooter = _
"Page " & Pg & " of " & Ct
ActiveSheet.PrintOut
Pg = Pg + 1
End If
Next k
End With
End Sub
"Saintsman" wrote in message
...
I have some code which produces a list of all the sheets in a Workbook, but
I
want to add some user choice on which sheets are printed
ie on a sheet1 (a contents page basically)
COLA COLB
Sheet Name Print
sheet1 N
sheet2 Y
sheet3 N
sheet4 Y
ETC NB growing list of sheets to about 100
They will need to be grouped so page numbering works (1 of 50)
Anybody able to help?
|