Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to print specific sheets based on cell values in Excel?

Author Sun Last modified

Have you ever tried to print specific sheets based on a cell value? In this article, I will provide some examples to address this issue. If you're interested, please continue reading.

Print sheet based on a cell with VBA

Print sheet based on adjacent cell with VBA


Print sheet based on a cell with VBA

Supposing there are two sheets, you want to print Sheet1 or Sheet2 or both sheets based on Cell A1 in the Sheet1. Please do as below:

In this case, enter 1 indicates to print the first sheet, enter 2 to print the second sheet, and 3 to print both sheets.

1. Enter 1, 2, or 3 as you need to A1 in the first sheet, and press Alt + F11 keys to open Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste below code in the Module script. See screenshot:
A screenshot of inserting a Module in the VBA window

VBA: Print Sheet based on cell value

Sub PrintStuff()
'UpdayebyExtendoffice20180811
    Dim xRgVal As Variant
    Dim xSheets As Sheets
    Set xSheets = ActiveWorkbook.Worksheets
    xRgVal = xSheets(1).Range("A1").Value
    If (IsNumeric(xRgVal)) And (Len(xRgVal) = 1) Then
        Select Case xRgVal
            Case 1
                xSheets(1).PrintOut
            Case 2
                xSheets(2).PrintOut
            Case 3
                xSheets(1).PrintOut
                xSheets(2).PrintOut
            Case Else
                MsgBox "Enter1, 2 or 3 into A1 (1 print Sheet1 2 print Sheet2 3 print Sheet1 and Sheet2 ", , "KuTools For Excel"
                Exit Sub
            End Select
    Else
        Exit Sub
    End If
End Sub

A screenshot of VBA code inserted in the Module window

3. Press F5 key to directly print the sheet(s).


Print sheet based on adjacent cell with VBA

If you have multiple sheets in a workbook, and you want to print one or several sheets based on cell values from this workbook, you can do as below:

1. Create a new sheet named Control Sheet in the workbook you use, and list all sheet name in column A (include or exclude the control sheet as you need). See screenshot:
A screenshot showing the 'Control Sheet' with sheet names listed in column A in Excel

2. Type “print” in the adjacent cell next to the sheet name if you want to print it. See screenshot shown.
A screenshot of the 'Control Sheet' with 'print' values entered in the adjacent cells next to the sheet names

3. Press Alt + F11 keys to enable the Microsoft Visual Basic for Applications window, and click Insert > Module. See screenshot:
A screenshot of inserting a Module in the VBA window

4. Paste below code to the Module, and press F5 key to run the code.

VBA: Print based on adjacent cell

Sub CreateControlSheet()
'UpdatebyExtendoffice20170811
    Dim i As Integer
    Dim xCSheetRow As Integer
    Dim xSName As String
    Dim xCSheet As Variant
    Dim xRgVal As String
    On Error Resume Next
    xSName = "Control Sheet"
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Set xCSheet = ActiveWorkbook.Worksheets(xSName)
    xCSheetRow = xCSheet.Range("B65536").End(xlUp).Row
    For i = 2 To xCSheetRow
        xRgVal = xCSheet.Range("B" & i).Value
        If xRgVal = "Print" Or xRgVal = "print" Then
            If xCSheet.Range("A" & i).Value <> "" Then
                ActiveWorkbook.Worksheets(xCSheet.Range("A" & i).Value).PrintOut
            End If
        End If
    Next
    xCSheet.Delete
    ActiveWorkbook.Worksheets.Add
    ActiveSheet.Name = "Control Sheet"
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Sheet Name"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "Print?"
    For i = 1 To ActiveWorkbook.Worksheets.Count
        Range("A" & i + 1).Value = ActiveWorkbook.Worksheets(i).Name
    Next
    Cells.Columns.AutoFit
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

A screenshot of VBA code inserted in the Module window

After running the code, the sheet(s) will be printed right now, and at the same time, a new Control Sheet will replace the old one.

Tip: If you have Kutools for Excel, with its Create List of Sheet Names utility, you can quickly create a list of all sheet name in a new sheet with a clickable link.

A screenshot of a Control Sheet with clickable links to sheet names after using Kutools

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in