page break preview says 2 pages, print preview says 3

yky

Well-known Member
Joined
Jun 7, 2011
Messages
1,881
Office Version
  1. 2010
Platform
  1. Windows
I have this file which, in page break preview, shows only two pages, page 1 and page 2, enclosed by blue lines. Page 2 isn't a full page, only about half a page. Nowhere can page 3 be seen. However, when printing, it gives 3 pages, the last page being blank. In print preview, it shows in the bottom page 1 of 3, page 2 of 3, page 3 of 3 as I scroll through the pages.

I wonder why this happens and how to get rid of the last page. I tried to delete the rows beyond the last used row and columns beyond the last used column. That did not help.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
yky, perhaps you have a selected range for print area somewhere in the sheet which you are not seeing ? Did you try to select your print area all over again ?

Try the below code, it should give you the range for page 3

Code:
Sub Print_Area()

Dim Print_Area As String, x As Byte
Print_Area = ActiveSheet.PageSetup.PrintArea

Print_Area = Replace(Print_Area, "$", "")
x = InStr(3, Print_Area, ",")

MsgBox "Page 3 range is " & Right(Print_Area, x)

End Sub

Let me know if this helps you
 
Upvote 0
Thanks for the reply.

The code gave a message that said "Page 3 range is ". That means the print area is not set. So it defaults to the entire sheet.
 
Upvote 0
Have you tried to select the print area all over again ? Select your page 1 then Alt > P > R > S ... Then select your page 2 then Alt > P > R > A

I have changed the code a bit but I still noticed some limitations where if 2 pages (print areas) are connected with only a page break the codes doesn't pick it up as 2 pages

Code:
Sub Print_Area()

Dim Print_Area As String, x As Long, Arr() As String

Print_Area = ActiveSheet.PageSetup.PrintArea
Print_Area = Replace(Print_Area, "$", "")

For x = 1 To ActiveSheet.PageSetup.Pages.Count
    Arr() = Split(Print_Area, ",")
Next x

Print_Area = ""

For x = LBound(Arr) To UBound(Arr)
    Print_Area = Print_Area & "Page " & x + 1 & " print area is " & Arr(x) & vbNewLine
Next x

MsgBox Print_Area

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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