Excel Button to Print Specific Sheets: 7 Easy Methods

There are three different sheets in our reference Excel file. We will print specific sheets from that file using the Excel button.

 


Method 1 – Add the Developer Tab in Excel

  • Go to File > Options.
  • Select Customize Ribbon of the Excel Options window.
  • Mark the Developer option.
  • Press OK on the window.

Create a Button to Print Particular Excel Sheets

The Developer tab has been added to the Ribbon section.


Method 2 – Create a List Using ActiveX Controls

  • Go to the Developer tab.
  • Click the Insert option.
  • Choose the List Box option from the ActiveX Controls.

Create a Button to Print Particular Excel Sheets

  • Move the cursor to any blank space of the dataset.

  • Press the right button of the mouse.
  • Choose Properties from the Context Menu.

  • The Properties window will appear now.
  • Modify the (Name) section to Sheet_List.
  • Go to MultiSelect drop-down list and choose the 2 – fmMultiSelectExtended. Save the changes.

Create a Button to Print Particular Excel Sheets

2 – fmMultiSelectExtended option offers to select multiple cells using the Ctrl or Shift buttons.


Method 3 – Customize the ActiveX Box

  • Go to the dataset and move the cursor to the Control Box.
  • Press the mouse’s right button again.
  • Choose the View Code option from the Context Menu. Or press Alt+F11.

  • Choose the Worksheet option from the Object drop-down list.

Create a Button to Print Particular Excel Sheets

  • There is SelectionChange on the default Event on the right side of the VBA window.
  • Change the Event to Active.

Create a Button to Print Particular Excel Sheets

  • Write the following VBA code.
Private Sub Worksheet_Activate()
Dim Sheet_Name
Me.Sheet_List.Clear
For Each Sheet_Name In ThisWorkbook.Sheets
Me.Sheet_List.AddItem Sheet_Name.Name
Next Sheet_Name
End Sub

Create a Button to Print Particular Excel Sheets

  • Run the VBA code by pressing the F5 button.

The sheet names are shown as a list.

Code Explanation:

Dim Sheet_Name

Define the variables.

Me.Sheet_List.Clear

It clears all the previous values from the Sheet_List variable.

For Each Sheet_Name In ThisWorkbook.Sheets

This selects each sheet of the Excel file.

Me.Sheet_List.AddItem

It adds all the sheets into the Sheet_List variable.


Method 4 – Add Custom VBA Code to Print Sheet

  • Choose the Module option from the Insert tab.

  • Copy and paste the following VBA code on the module.
Sub print_specific_sheets()
Dim n As Long, m As Long
Dim array_1() As String
With ActiveSheet.Sheet_List
For n = 0 To .ListCount - 1
If .Selected(n) Then
ReDim Preserve array_1(m)
array_1(m) = .List(n)
m = m + 1
End If
Next n
Sheets(array_1()).PrintOut
End With
End Sub

Create a Button to Print Particular Excel Sheets

Code Explanation:

Dim n As Long, m As Long
Dim array_1() As String

Define the variables.

With ActiveSheet.Sheet_List

Select the active sheet of the Sheet_List variable.

For n = 0 To .ListCount - 1

Apply a for loop from 0.

If .Selected(n) Then
                ReDim Preserve array_1(m)
                array_1(m) = .List(n)
                m = m + 1

The If function is applied with the VBA ReDim function used to resize a dynamic array.

    Sheets(array_1()).PrintOut

This command is used to print out a sheet.


Method 5 – Disable Design Mode

  • To disable this, click on the Design Mode from the Developer tab.

Create a Button to Print Particular Excel Sheets


Method 6 – Create a Control Button for Print

  • Select the Insert option from the Developer tab.
  • Choose a Button from the Form Controls option.

Create a Button to Print Particular Excel Sheets


Method 6 – Assign the Macro to the Print Button

  • Move the cursor to any blank space of the dataset. The Assign Macro will pop up. Click OK.

  • A button was added to the dataset. Edit the button and change the name to Print Button.

  • Click on any of the Sheets from the list and click on Print Button.

Create a Button to Print Particular Excel Sheets

A pop up mentioning the printing command is showing here.

Choose sheets from the list and then press the Print Button to get your desired sheet to print.


Method 7 – Add an Icon to Print Specific Excel Sheet

  • Choose the Illustration option from the Insert tab.
  • Click on Icons and choose your desired icon.

  • Place the data set icon and assign the macro as shown previously.

This Icon will work exactly like the Print Button. Choose the sheet from the list and click on this icon.


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


Related Articles

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Alok Paul
Alok Paul

Alok Paul has completed his B.Sc. in Electronics and Telecommunication Engineering from East West University. He has been working on the ExcelDemy project for more than 2 years. He has written 220+ articles and replied to numerous comments. He is experienced in Microsoft Office, especially in Excel. He also led some teams on Excel and VBA content development. He has a keen interest in Advanced Excel, Data analysis, Excel Pivot Table, Charts, and Dashboard. He loves to research... Read Full Bio

9 Comments
  1. Instead of printing, how can we adjust the VBA code to save the selected sheet in the list as a PDF in a location of our choice?

  2. Hi!
    Anyway to create a locked list, instead of generating one? Every time I open the workbook, my list is empty.

    • Hello SAM,

      We have attached an Excel file with this reply which you can download from the link below.
      Print-Sheets-Using-Excel-Button.xlsm

      Here, we’ve modified the code such that it automatically lists the names of the worksheets when opened. You can select multiple worksheets and press the print button to print them.

      Regards,
      ExcelDemy

  3. Thank you for the code it works as indicated. How can I print multiple sheets (30)?

  4. Hello,

    I would like to do something more;

    1- Can we create a list for all visible sheets instead of all sheets from workbook?
    2- I would like to pick the printer after the press “print” button. Can you show me how can I do?

    • Thank you CANER for your queries.
      1. If you want to create a list for only visible sheets, you need to modify the Worksheet_Activate() subroutine in the following way:

      Private Sub Worksheet_Activate()
          Dim Sheet_Name As Worksheet
          Me.Sheet_List.Clear
          For Each Sheet_Name In ThisWorkbook.Sheets
              'only taking visible sheet in the list
              If Sheet_Name.Visible = xlSheetVisible Then
                  Me.Sheet_List.AddItem Sheet_Name.Name
              End If
          Next Sheet_Name
      End Sub
      

      Here, I have added an extra IF statement so that the code only adds the sheets that are visible to the list.

      2. If you want to choose the printer before printing, you need to modify the print_specific_sheets subroutine in the following way:

      Sub print_specific_sheets()
      Dim n As Long, m As Long
      Dim array_1() As Variant
      m = 0
          With ActiveSheet.Sheet_List
              If .ListCount = 0 Then
                  MsgBox "No Sheet Selected"
                  Exit Sub
              End If
              For n = 0 To .ListCount - 1
                  If .Selected(n) Then
                      ReDim Preserve array_1(m)
                      array_1(m) = .List(n)
                      m = m + 1
                  End If
              Next n
              'Opening Printer Setup Dialogue box
              Application.Dialogs(xlDialogPrinterSetup).Show
              Sheets(array_1()).PrintOut
          End With
      End Sub
      

      Here, I only added the following line to show the Printer Setup dialogue box from where you can choose from available printers.

      Application.Dialogs(xlDialogPrinterSetup).Show
      

      I hope it solves your problem.

      Regards
      Aniruddah
      Team Exceldemy

  5. few if any I encountered are willing to help. This one is an exception !!

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo