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
 
And, I'd really like to be able to automatically hide the columns after the macro has run?
Uncomment it in the code, it was only commented for testing purposes
That's it! Is there any way for force the Show Print Preview?
Can't help with that I'm afraid, as I get what I showed in post number 14.
You can try adding
VBA Code:
Sheets("2021").PrintPreview
after the
VBA Code:
Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint"
but no idea how it will react as can't replicate what you are seeing to test.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Unfortunately I'm back to where I started with the .PrintPreview only showing the first page.
 
Upvote 0
Hi Mark. Just for your info, I found the issue. I simply needed to remove:
VBA Code:
Application.ScreenUpdating = False

It all functions perfectly to display the multiple pages!!! Thanks so much for your persistence and support.
 
Upvote 0
Hi Mark. Just for your info, I found the issue. I simply needed to remove:
VBA Code:
Application.ScreenUpdating = False

It all functions perfectly to display the multiple pages!!! Thanks so much for your persistence and support.
Interesting, thanks for the feedback (although I would leave it there and just place
VBA Code:
Application.ScreenUpdating = True
before the PrintPreview line).
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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