Forum Discussion

dchiggins54's avatar
dchiggins54
Copper Contributor
Aug 29, 2019
Solved

Is there a way to use a macro to find a print area when it varies with each run?

Hi All...   I have a situation where I'm trying to set the print area for 23 different worksheets in one file using a macro.  The columns are the same on each worksheet, but number of rows is diffe...
  • JKPieterse's avatar
    Aug 30, 2019

    dchiggins54 This macro would set the print-area of each sheet for columns A:N for as many rows as there is data in the sheet:

    Sub SetPrintAreas()
        Dim Sh As Worksheet
        For Each Sh In Worksheets
            With Sh.PageSetup
                .PrintArea = Intersect(Sh.UsedRange, Sh.Range("A:N")).Address
            End With
        Next
    End Sub

Resources