Skip to main content

Worksheets.PrintOut method

Prints the object.


expression.PrintOut (From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, IgnorePrintAreas)

expression A variable that represents a Worksheets object.


Name Required/Optional Data type Description
From Optional Variant The number of the page at which to start printing. If this argument is omitted, printing starts at the beginning.
To Optional Variant The number of the last page to print. If this argument is omitted, printing ends with the last page.
Copies Optional Variant The number of copies to print. If this argument is omitted, one copy is printed.
Preview Optional Variant True to have Microsoft Excel invoke print preview before printing the object. False (or omitted) to print the object immediately.
ActivePrinter Optional Variant Sets the name of the active printer.
PrintToFile Optional Variant True to print to a file. If PrToFileName is not specified, Microsoft Excel prompts the user to enter the name of the output file.
Collate Optional Variant True to collate multiple copies.
PrToFileName Optional Variant If PrintToFile is set to True, this argument specifies the name of the file that you want to print to.
IgnorePrintAreas Optional Variant True to ignore print areas and print the entire object.

Return value



"Pages" in the descriptions of From and To refers to printed pages, not overall pages in the sheet or workbook.

In Excel, when you click the Print button, Excel will not print hidden sheets, except use VBA.


Print Worksheets on One Page

'Print Sheet1 exactly one page wide and tall
With Worksheets("Sheet1").PageSetup
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 1
End With

Print Worksheets with Comments

Sub PrintWorksheetsWithComments()
    'Display all comments
    Application.DisplayCommentIndicator = xlCommentAndIndicator
    With ActiveSheet
        'As displayed on sheet
        .PageSetup.PrintComments = xlPrintInPlace
        'Print the active sheet
    End With
End Sub

Print Only Hidden Worksheets

Sub PrintOnlyHiddenWorksheets()
    Dim CurVis As Long
    Dim sh As Worksheet
    For Each sh In ActiveWorkbook.Worksheets
        With sh
            CurVis = .Visible
            If CurVis >= 0 Then
                .Visible = xlSheetVisible
                .Visible = CurVis
            End If
        End With
    Next sh
End Sub

Print Visible and Hidden Worksheets

Sub PrintHiddenAndVisibleWorksheets()
    Dim CurVis As Long
    Dim sh As Worksheet
    For Each sh In ActiveWorkbook.Worksheets
        With sh
            CurVis = .Visible
            .Visible = xlSheetVisible
            .Visible = CurVis
        End With
    Next sh
End Sub

Print Multiple Worksheets

'Print Sheet2 and Sheet3
Worksheets(Array("Sheet2", "Sheet3")).PrintOut

Print All Worksheets

'Print all worksheets

Print All Charts

'Print all Charts

Print Whole Workbook

'Print the active whole workbook
'Print this workbook which the VBA code in

Print a Specific Sheet

'Print only "Sheet2"

Print the Active Sheet

'only the activesheet

Print Selected Sheets

'Print all selected sheets

Print Selection

'Print only the selection

Print A Range

'Print range A1:C6

Print preview

'Active sheet print preview
ActiveSheet.PrintOut preview:=True

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>