VBA multiple Non-Contiguous Print area with lastrow

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
Lr1 = Range("AG1")
 Lr2 = Range("AG65")
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = "$A$1:$B$" & Lr1 & ",$D$1:$E$" & Lr1 & ",$G$1:$H$" & Lr1 & ",$J$1:$K$" & Lr1 & ",$M$1:$N$" & Lr1 & _
                                        ",$P$1:$Q$" & Lr1 & ",$S$1:$T$" & Lr1 & ",$V$1:$W$" & Lr1 & ",$Y$1:$Z$" & Lr1 & ",$AB$1:$AC$" & Lr1 & _
                                        ",$A$65:$B$" & Lr2 & ",$D$65:$E$" & Lr2 & ",$G$65:$H$" & Lr2 & ",$J$65:$K$" & Lr2 & ",$M$65:$N$" & Lr2 & _
                                        ",$P$65:$Q$" & Lr2 & ",$S$65:$T$" & Lr2 & ",$V$65:$W$" & Lr2 & ",$Y$65:$Z$" & Lr2 & ",$AB$65:$AC$" & Lr2 & _
    Application.PrintCommunication = False

where AG1=37 and AG65=94

I'm not sure what I need to do to get the above Printarea to get fixed. but I need A1:B and Lr1 , D1:E and Lr1 so on.

using the above somehow selects A1:AO124 contiguous print area not sure why. Any help is greatly appreciated
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,784
Messages
6,121,539
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top