VBA Print Preview only displaying 1 page

Jasesair

Active Member
Joined
Apr 8, 2015
Messages
282
Office Version
  1. 2016
Having a little trouble with the below code. It's only displaying one page when more data exists for a second print preview page.

VBA Code:
Sub PrintJuniors2021()
Dim LastRow As Long
Application.ScreenUpdating = False
Columns("AN:BQ").EntireColumn.Hidden = False
LastRow = Sheets("2021").Range("AO" & Rows.Count).End(xlUp).Row
Sheets("2021").PageSetup.PrintArea = "AO2:AT107" & LastRow
With ActiveSheet.PageSetup
    .Orientation = xlLandscape
    End With
ActiveSheet.PrintPreview
Columns("AN:BQ").EntireColumn.Hidden = True
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try
VBA Code:
Sheets("2021").PageSetup.PrintArea = "AO2:AT" & LastRow
 
Upvote 0
Same result unfortunately. It's allowing for me to click on 'next page' but continues to just show the first page.
 
Upvote 0
What do you get with
VBA Code:
Sub PrintJuniors2021()
    Dim LastRow As Long
    Application.ScreenUpdating = False
    Sheets("2021").Columns("AN:BQ").Hidden = False
    LastRow = Sheets("2021").Range("AO" & Rows.Count).End(xlUp).Row
    Sheets("2021").PageSetup.PrintArea = Sheets("2021").Range("AO2:AT" & LastRow).Address
    Sheets("2021").PageSetup.Orientation = xlLandscape
    Sheets("2021").PrintPreview
    Sheets("2021").Columns("AN:BQ").Hidden = True
End Sub

and what is the row number of the last cell with data in column AO on sheet 2021?
 
Upvote 0
Same result unfortunately.

AO last row with data is row 58. It is currently print previewing only to row 37.
 
Upvote 0
...and with?

VBA Code:
Sub PrintJuniors2021()
    Dim LastRow As Long
    Application.ScreenUpdating = False
    Sheets("2021").Columns("AN:BQ").Hidden = False
    LastRow = Sheets("2021").Range("AO" & Rows.Count).End(xlUp).Row
    Sheets("2021").PageSetup.PrintArea = Sheets("2021").Range("AO2:AT" & LastRow).Address
    With Sheets("2021").PageSetup
        .Orientation = xlLandscape
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 2
    End With
    Sheets("2021").PrintPreview
    'Sheets("2021").Columns("AN:BQ").Hidden = True
End Sub
 
Upvote 0
That fits all rows (up to row 58) onto the one page. The size is obviously reduced to produce this.
 
Upvote 0
What do you get with the below?

VBA Code:
Sub PrintJuniors2021()
    Dim LastRow As Long
    Application.ScreenUpdating = False
    Sheets("2021").Columns("AN:BQ").Hidden = False
    LastRow = Sheets("2021").Range("AO" & Rows.Count).End(xlUp).Row
    Sheets("2021").PageSetup.PrintArea = ""

    With Sheets("2021").PageSetup
    .PrintArea = Sheets("2021").Range("AO2:AT" & LastRow).Address
        .Orientation = xlLandscape
        .Zoom = False
    End With
    Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
    Sheets("2021").Columns("AN:BQ").Hidden = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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