Set Print Areas for Multiple Excel Worksheets with VBA
Question details
Set print areas and consistent page settings for more than 200 worksheets using VBA.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user wants each worksheet configured with half-inch margins, landscape orientation, and scaling to one page wide.
- Observed behavior
- Each worksheet should print its intended content one page wide, with rows allowed to continue onto additional pages.
Check that each worksheet's used range contains the cells you want to print; formatting in distant cells can make it larger than expected. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros if prompted.
Apply print settings to every worksheet with a VBA macro
Use this macro to configure all worksheets at once, then review the results before printing.
The macro uses each sheet's UsedRange as its print area. It sets the left, right, top, and bottom margins to 0.5 inches and allows an unlimited number of pages tall.
In Excel, open the workbook and select Developer > Visual Basic. If the Developer tab is hidden, enable it through File > Options > Customize Ribbon.
In the VBA editor, select Insert > Module, then paste this code: Sub SetPrintAreas() Dim W As Worksheet For Each W In ThisWorkbook.Worksheets With W.PageSetup .PrintArea = W.UsedRange.Address .LeftMargin = Application.InchesToPoints(0.5) .RightMargin = Application.InchesToPoints(0.5) .TopMargin = Application.InchesToPoints(0.5) .BottomMargin = Application.InchesToPoints(0.5) .Orientation = xlLandscape .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = False End With Next W End Sub
Place the cursor inside SetPrintAreas and select Run > Run Sub/UserForm, or press F5. In Excel, select a few worksheets and open File > Print to check their previews.
When the previews look right, select File > Print and choose Print Entire Workbook. Alternatively, add W.PrintOut after the End With line in the loop and run the macro to print each sheet automatically.

Review and Print Excel Workbooks with WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and printing Excel workbooks. Its format compatibility helps with migration, though Excel VBA macros and their behavior may differ in WPS.

Frequently Asked Questions
Why is the print area larger than my data?
UsedRange can include cells with formatting beyond the visible data. If the intended data is contiguous, replace W.UsedRange.Address with W.Range("A1").CurrentRegion.Address, using a cell inside the desired region instead of A1.
Why does the macro set Zoom to False?
In VBA, PageSetup.Zoom must be False for FitToPagesWide and FitToPagesTall scaling to take effect. The macro then sets FitToPagesWide to 1.
Can I make each worksheet fit within five pages tall?
Yes. In the macro, change .FitToPagesTall = False to .FitToPagesTall = 5. Check File > Print afterward because fitting to a page limit can make the content smaller.
Does the macro print the sheets immediately?
No. The supplied macro only changes page settings. After checking File > Print, choose Print Entire Workbook, or add W.PrintOut inside the loop to print each sheet automatically.




