Vba set non contiguous print in Excel

For example, in my WorkSheet I want to print only 2 tables (one table range is "A2:D34" and another table range is "AM47:AQ60") leaving out the rest of the WorkSheet contents.

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub PrintSetUp()
  3. ActiveSheet.PageSetup.PrintArea = "A2:D34,AM47:AQ60"
  4. With ActiveSheet.PageSetup
  5. .CenterFooter = "Page &P of &N"
  6. .CenterHorizontally = True
  7. .CenterVertically = False
  8. .Orientation = xlLandscape
  9. .PaperSize = xlPaperA4
  10. .Zoom = 100
  11. End With
  12. End Sub

Description:

a) Line 3 - Each range to be printed should be specified with "," in between them as in "A2:D34,AM47:AQ60"".

 

You can find similar Excel Questions and Answer hereunder

1) How can I set the fill color, font color and set number format of cell to date?

2) How can I hide a sheet completely from users (the sheet should not even appear in Unhide dialog box)?

3) How can I find the number of working days between 2 dates using VBA?

4) How can I loop through all ActiveX checkboxes in WorkSheet and set them to Unchecked status?

5) How can I set up ListBox using VBA to allow users to select multiple values?

6) How can I update a listbox based on data in a list using VBA?

7) How can I get row count of filtered data?

8) How can I add a Timestamp after macro execution?

9) I have to enter non alphanumeric characters in a cell using VBA - how can I get their codes for use in VBA?

10) How to use the trace error function in VBA

 

Here the previous and next chapter