You can name the range and then use the named range as the print area.
Range("A1:I16,A25:I35,A64:I81").Name = "MyPrintRange"
ActiveSheet.PageSetup.PrintArea = "MyPrintRange"
However, the above will insert a page feed between the non contiguous rows.
In Page setup it also converts the named range to actual cell addresses.
You can copy the non contiguous rows to a separate temporary worksheet and
there will be no non contiguous rows and then the address of the UsedRange
can be used for the PrintArea.
Sub PrtNonContiguous()
With Sheets("Sheet1")
.Range("A1:I16,A25:I35,A64:I81").Copy _
Sheets("Sheet2").Range("A1")
End With
With Sheets("Sheet2")
.PageSetup.PrintArea = .UsedRange.Address
End With
End Sub
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.