Print Table on One Page

NorthbyNorthwest

Board Regular
Joined
Oct 27, 2013
Messages
154
Office Version
  1. 365
Hi, everyone. I'm trying to print a table (listobject) on a single page. But the code fails and prints table on two pages. Could someone tell me what I'm doing wrong?
VBA Code:
Sub PrintAssignments()
Sheet11.Activate
With ActiveSheet
    .PageSetup.PrintArea = .ListObjects("Assignment").Range
    .PageSetup.Orientation = xlLandscape
    .PageSetup.FitToPagesWide = 1
    .PageSetup.FitToPagesTall = 1
End With
ActiveSheet.ListObjects("Assignment").Range.PrintOut
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi,

AFAIK FitToPagesWide = 1 is the parameter to fit in the ListObject to match the width of the page. Only those records fitting in will get printed on page 1, any more will follow up on page 2.

Maybe this is what you want to get:

VBA Code:
Sub PrintAssignments_mod()
' https://www.mrexcel.com/board/threads/print-table-on-one-page.1223624/
With Sheet11
  With .PageSetup
    .PrintArea = Sheet11.ListObjects("Assignment").Range.Address
      .CenterHorizontally = True
      .CenterVertically = True
      .Orientation = xlLandscape
      .Zoom = False
      .FitToPagesWide = False
      .FitToPagesTall = 1
  End With
  .ListObjects("Assignment").Range.PrintOut
End With
End Sub

Ciao,
Holger
 
Upvote 0
Solution
Hi,

AFAIK FitToPagesWide = 1 is the parameter to fit in the ListObject to match the width of the page. Only those records fitting in will get printed on page 1, any more will follow up on page 2.

Maybe this is what you want to get:

VBA Code:
Sub PrintAssignments_mod()
' https://www.mrexcel.com/board/threads/print-table-on-one-page.1223624/
With Sheet11
  With .PageSetup
    .PrintArea = Sheet11.ListObjects("Assignment").Range.Address
      .CenterHorizontally = True
      .CenterVertically = True
      .Orientation = xlLandscape
      .Zoom = False
      .FitToPagesWide = False
      .FitToPagesTall = 1
  End With
  .ListObjects("Assignment").Range.PrintOut
End With
End Sub

Ciao,
Holger
Thanks for the response, Holger. You are correct, it was the columns which were forcing a second page.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

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