In this tutorial, you will learn how to select print area in Excel manually and how to set print ranges for multiple sheets by using macros.
When you hit the Print button in Excel, the entire spreadsheet is printed by default, which often takes multiple pages. But what if you don't really need all the content of a huge worksheet on paper? Luckily, Excel provides the ability define the parts for printing. This feature is known as Print Area.
A print area is a range of cells to be included in the final printout. In case you don't want to print the entire spreadsheet, set a print area that includes only your selection.
When you press Ctrl + P or click the Print button on a sheet that has a defined print area, only that area will be printed.
You can select multiple print areas in a single worksheet, and each area will print on a separate page. Saving the workbook also saves the print area. If you change your mind at a later point, you can clear the print area or change it.
Defining a print area gives you more control over what each printed page looks like and, ideally, you should always set a print area before sending a worksheet to the printer. Without it, you may end up with messy, hard to read pages where some important rows and columns are cut off, especially if your worksheet is bigger than the paper you are using.
To instruct Excel which section of your data should appear in a printed copy, proceed in one of the following ways.
The quickest way to set a constant print range is this:
A faint gray line will appear denoting the print area.
Want to visually see all your settings? Here's a more transparent approach to defining a print area:
To print a few different parts of a worksheet, you can select multiple print areas in this way:
Done! Multiple print areas are created, each one representing its own page.
When you want a hard copy of a whole sheet or entire workbook but do not want to bother clearing all the print areas, just tell Excel to ignore them:
The ability to print multiple areas per sheet of paper is controlled by a printer model, not by Excel. To check if this option is available to you, press Ctrl + P, click the Printer Properties link, and then switch through the available tabs of the Printer Properties dialog box searching for the Pages per Sheet option.
If your printer has such an option, lucky you are :) If there is no such option, then the only way I can think of is copying the print ranges to a new sheet. With the help of the Paste Special feature, you can link the copied ranges to the original data in this way:
In case you have a lot of worksheets with exactly the same structure, you will obviously want to output the same rage on paper. The problem is that selecting several sheets disables the Print Area button on the ribbon. Luckily, there is an easy workaround described in How to print the same range in multiple sheets.
If you have to print the same area on multiple sheets regularly, the use of VBA can speed up things.
This macro automatically sets the print area(s) for all selected worksheets the same as on the active sheet. When multiple sheets are selected, the active sheet is the one which is visible when you run the macro.
Sub SetPrintAreaSelectedSheets() Dim CurrentPrintArea As String Dim Sheet As Worksheet CurrentPrintArea = ActiveSheet.PageSetup.PrintArea For Each Sheet In ActiveWindow.SelectedSheets Sheet.PageSetup.PrintArea = CurrentPrintArea Next End Sub
No matter how many sheets you have, this code defines the print range in a whole workbook in one go. Simply, set the desired print area(s) on the active sheet and run the macro:
Sub SetPrintAreaAllSheets() Dim CurrentPrintArea As String Dim Sheet As Worksheet CurrentPrintArea = ActiveSheet.PageSetup.PrintArea For Each Sheet In ActiveWorkbook.Sheets If Sheet.Name <> ActiveSheet.Name Then Sheet.PageSetup.PrintArea = CurrentPrintArea End If Next End Sub
When working with different workbooks, you may find it convenient if the macro prompts you to select a range.
Here's how it works: you select all the target worksheets, run the macro, select one or more ranges when prompted (to select multiple ranges, hold the Ctrl key), and click OK.
Sub SetPrintAreaMultipleSheets() Dim SelectedPrintAreaRange As Range Dim SelectedPrintAreaRangeAddress As String Dim Sheet As Worksheet On Error Resume Next Set SelectedPrintAreaRange = Application.InputBox("Please select the print area range", "Set Print Area in Multiple Sheets", Type:=8) If Not SelectedPrintAreaRange Is Nothing Then SelectedPrintAreaRangeAddress = SelectedPrintAreaRange.Address(True, True, xlA1, False) For Each Sheet In ActiveWindow.SelectedSheets Sheet.PageSetup.PrintArea = SelectedPrintAreaRangeAddress Next End If Set SelectedPrintAreaRange = Nothing End Sub
The easiest way is to download our sample workbook with Print Area Macros and run a macro directly from that workbook. Here's how:
The sample workbook contains the following macros:
Alternatively, you can save your file as a macro-enabled workbook (.xlsm) and add a macro to it. For the detailed step-by-step instructions, please see How to insert and run VBA code in Excel.
Accidentally included irrelevant data or missed selecting a few important cells? No problem, there are 3 easy ways to edit print area in Excel.
To add more cells to the existing print area, just do the following:
Done!
This is of course the fastest way to modify print area, but not transparent. To get it right, here are a few important things to remember:
Every time you set a print area in Excel, a defined range named Print_Area is created, and there is nothing that would prevent you from modifying that range directly. Here's how:
Another quick way to adjust print area in Excel is to use the Page Setup dialog box. The best thing about this method is that it lets you make any changes you want – modify the print area, delete or add a new one.
Clearing the print area is as easy as setting it :)
If you frequently share your workbooks with other people, you may want to protect the print area so that no one could mess up your printouts. Regrettably, there is no direct way to lock the print area in Excel even by protecting a worksheet or workbook.
The only working solution to protect print area in Excel is with VBA. For this, you add the Workbook_BeforePrint event handler that silently forces the specified print area just before printing.
A simpler way would be to set the event handler for the active sheet, but this works with the following caveats:
Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.PrintArea = "A1:D10" End Sub
If different sheets have different structure, then specify the print area for each sheet individually.
Private Sub Workbook_BeforePrint(Cancel As Boolean) Worksheets("Sheet1").PageSetup.PrintArea = "A1:D10" Worksheets("Sheet2").PageSetup.PrintArea = "A1:F10" End Sub
The above macro sets the print area to A1:D10 for Sheet1 and to A1:F10 for Sheet2. You are free to change these as desired as well as to add more sheets.
To add the event handler in your workbook, carry out these steps:
Most printing problems in Excel usually relate to the printer settings rather than print area. Nevertheless, the following troubleshooting tips may come in helpful when Excel is not printing the correct data.
Problem: You can't get Excel to accept the print area that you define. The Print Area field shows some odd ranges, but not the ones you have entered.
Solution: Try to clear print area completely, and then select it anew.
Problem: You have selected a certain number of columns for the print area, but not all of them are printed.
Solution: Most likely, the column width exceeds the paper size. Try making the margins narrower or adjust scaling – choose Fit All Columns on One Page.
Problem: You want the one-page printout, but it prints on several pages.
Solution: Non-adjacent rages are printed on individual pages by design. If you selected just one range but it gets split to several pages, then most probably it is bigger than the paper size. To fix this, try setting all margins close to 0 or choose Fit Sheet on One Page. For more details, please see How to print Excel spreadsheet on one page.
That's how you set, change and clear print area in Excel. I thank you for reading and hope to see you on our blog next week!
3 responses to "Excel print area: how to set, change and clear"
I wish to have a constant number of lines printed in a multi-page worksheet, without having to manually adjust.
The worksheet is under constant change with lines inserted and deleted but I wish to be able to print the same number of lines per page regardless. eg 35lines each page
The worksheet has a fixed number of columns and that does not vary - only the addition/deletion of lines.
I would like to print all the Payslips by "Set Print Area" that are generated into Single Excel Files.
Is there any VBA code that would allow me to Macro this?
I understand how to create more than 1 print area on a single worksheet.
Is there a way to have each a different page size for each print area be set at the same time (preferably without using VBA)?