Lori wrote concerning a problem she was having with Excel. It seemed that the page setup for every worksheet in every workbook had changed. Worksheets that previously printed on a single page no longer fit on one page, instead printing on two.
The most likely explanations for behavior such as this is that something has changed in relation to how you print your worksheets. I don't mean that you have gone in and changed your page setup—I mean that you have physically changed a printer on your system or that the printer driver used by your system has been changed. Making such changes can universally affect your worksheets.
It is also possible that the change is due to a change in your version of Excel. If you recently upgraded to a different version, then worksheets could be rendered differently by Excel than they used to be.
Unfortunately, the only way to solve this issue—regardless of the cause—is to manually go through each workbook and change the page setup information for each worksheet. It is time consuming, but the only solution available.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2578) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Resetting Page Setup.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
If you want to cram more of your worksheet onto each page of a printout, one way to do it is by using scaling. Here's how ...
Discover MoreDon't like the print margins that Excel uses by default? You can change the default by changing the workbook on which ...
Discover MoreNeed to print your worksheet on a non-standard paper size? Excel is rather limited in printing to such papers, and here ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2014-05-17 08:19:02
David Ruben
Of course if frequently take the spreadsheet between different computers or share between people, or as in my case adding or deleting rows destroys carefully crafted page splits along alphabetical entry in column A... then a macro can reset page breaks and the PrintArea; this is triggered by the Workbook_BeforePrint event. The following has constants to set PrintArea end column (presumes starts from column "A", and in example to column "H"), number of title rows at the top (e.g. 5), and the number of rows that will generally always fit depending on font a& fontsize (46 in this example with no enlarged top header text)
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Const iPageRows As Integer = 46
Const iTitleRows As Integer = 5
Const sEndColumn As String = "H"
Dim iBodyRows As Integer, iTopRow As Integer, iRow As Integer
On Error GoTo L_Quit
'Body of text is iPageLength less the iTitleRows rows
iBodyRows = iPageRows - iTitleRows
'Temporarily turn off screen updating
Application.ScreenUpdating = False
'Clear old pagebreaks
ActiveSheet.ResetAllPageBreaks
'Start with row after the header
iRow = iTitleRows + 1
L_TopPage:
'Set Top of current page row
iTopRow = iRow
L_Loop:
'Work through rows to add page breaks
iRow = iRow + 1
'check if reached end of table of data
If Range("A" & iRow) = "" Then GoTo L_Completed
'Pagebreak if new alphabet letter in column A or maximum lines per page
If UCase(Left(Range("A" & iRow), 1)) <> UCase(Left(Range("A" & iRow - 1), 1)) _
Or iRow - iTopRow > iBodyRows Then _
Rows(iRow & ":" & iRow).Select: _
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell: _
GoTo L_TopPage
GoTo L_Loop
L_Completed:
'Set the PrintArea and Title rows
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$" & iTitleRows
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$" & sEndColumn & "$" & (iRow - 1)
L_Quit:
Application.ScreenUpdating = True
End Sub
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments