VBA multiple Non-Contiguous Print area with lastrow

hajiali

Active Member
Joined
Sep 8, 2018
Messages
405
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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,141,204
Messages
5,704,952
Members
421,372
Latest member
Jamie11

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
Top