• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Print specific pages

Awesome excel wizards,

Does anyone know how to print specific pages within a print area?
Through code I put specific sheets in a printarea to pool them together, now i want to be able to exclude specific pages from the printarea.

With the .PrintOut options you can add the From and To option to make a continous selection to print. However I want to print for example page 1-5, 7-8. Is this possible?
How would the code look like?

The alternative would be to copy the file copy everything to values and then delete the rows).

Greets
Michael

Code:
Option Explicit

Sub PrintButton_Click()

  If Application.Dialogs(xlDialogPrinterSetup).Show = False Then
  MsgBox "Geannuleerd"
  Exit Sub
  End If

  Application.ScreenUpdating = False

  Dim i As Integer
  For i = 5 To 12
  If Sheets(1).Range("D" & i).Value = 1 Then Sheets(i - 4).Select False
  Next
  
  ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False

  Sheets(1).Select
  
 Application.ScreenUpdating = True
End Sub
 
I think i can just add multiple PrintOut lines for each contiguous section.
However this creates two print jobs, which i would like to avoid

Code:
.PrintOut From 1, To 5, Copies:=1, Collate:=True, IgnorePrintAreas
.PrintOut From 7, To 8, Copies:=1, Collate:=True, IgnorePrintAreas
 
I made some code to hide the columns i dont want to print. Works like a charm.
I guess for columns it would work the same way.
Hope anybody can use this for his work.

Gr. Michael
 
Back
Top