I am setting a print area using named range, since it's a table and it grows. When I execute, the headings wont print. How can I adjust this to print the named range(Table3) along with the headers?
I tried; ActiveSheet.PageSetup.PrintArea = Range("Table3{Headers}").Address
but only printed the Headers.
Application.Dialogs(xlDialogPrinterSetup).Show
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = Range("Table3").Address
Application.PrintCommunication = False
With ActiveSheet.PageSetup
I want the headers and Table3 to print.
A table is a ListObject
. Use the ListObject.Range
property to return the Range
that the table refers to (includes headers).
Dim myTbl as ListObject
Set myTbl = ThisWorkbook.Sheets("mysheetname").ListObjects("Table3")
...
ThisWorkbook.Sheets("mysheetname").PageSetup.PrintArea = myTbl.Range.Address
Change the sheet name as needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.