Excel VBA: Print Range of Cells – 5 Easy Methods

This is the sample dataset.

excel vba print range of cells


Method 1 – Using the Excel VBA PrintOut Method to Print a Range of Cells

Use VBA  to print only the Name and Age in the dataset.

Steps:

  • Open Visual Basic in the Developer Tab.

  • In the new window, select Insert >> Module.

excel vba print range of cells

  • Enter the following code in the VBA Module.
Sub PrintCriteria()
Range("B4:C10").PrintOut
End Sub

B4:C10 is defined to print using the Range Method and the PrintOut Method.

  • Go back to your sheet and run the Macro (PrintCriteria).

excel vba print range of cells

To Save the file for further use or to Print it later:

  • The Save window will open. Save your range as PDF and rename it (PrintOut Method, here)
  • Click Save.

  • Open the file to see the selected range.

excel vba print range of cells

To print it, press CTRL + P.

Read More: Excel VBA: Print Preview for Selected Range


Method 2 – Defining the Excel Sheet to Print a Range of Cells using Excel VBA

You want to print  the Name and Age only.

 

Steps:

  • Enter the following code in the VBA Module. (To see how to open a VBA Module, go to Method 1)
Sub DefiningSheet()
Sheets("Defining_Sheet").Range("B4:C10").PrintOut
End Sub

The Excel sheet is defined in the VBA ModuleB4:C10 inDefining_Sheet is selected.

  • Go back to your sheet and run the Macro (DefiningSheet).

excel vba print range of cells

To Save the file for further use or to Print it later:

  • The Save window will open. Save your range as PDF and rename it (Defining Sheet, here).
  • Click Save.

  • Open the file to see the selected range.

excel vba print range of cells

To print it, press CTRL + P.

Read More: How to Print Specific Sheets Using VBA Macro in Excel


Method 3 – Selecting a Range of Cells to Print using Excel VBA

You want to print Name, Age, and Occupation only.

Steps:

  • Enter the following code in the VBA Module. (To see how to open a VBA Module, go to Method 1)
Sub SelectionToPrint()
Selection.PrintOut
End Sub

The Selection Property was used in the PrintOut Method to print the selected range.

  • Go back to your sheet and select B4:D10.

excel vba print range of cells

  • Run the Macro (SelectionToPrint).

To Save the file for further use or to Print it later:

  • The Save window will open. Save your range as PDF and rename it (Printing by Selection, here).
  • Click Save.

excel vba print range of cells

 

  • Open the file to see the selected range.

To print it, press CTRL + P.

Read More: How to Set Print Area to Selection Using VBA in Excel


Method 4 – Defining a Range of Cells to print in the VBA Code in Excel

You want to print the information about the first four persons.

Steps:

  • Enter the following code in the VBA Module. (To see how to open a VBA Module, go to Method 1)
Sub PrintRangeMethod()
Sheets("Range_Method").Select
Range("B4:E8").Select
ActiveSheet.PageSetup.PrintArea = "B4:E8"
ActiveWindow.SelectedSheets.PrintOut From:=1, _
To:=1, Copies:=1, Collate:=True
End Sub

excel vba print range of cells

B4:E8 is defined, using the Range Method. It is set as the PrintArea and the PrintOut Method is used to print the selected range.

  • Go back to your sheet and Run the Macro (PrintRangeMethod).

To Save the file for further use or to Print it later:

  • The Save window will open. Save your range as PDF and rename it (Print by Range, here).
  • Click Save.

excel vba print range of cells

  • Open the file to see the selected range.

To print it, press CTRL + P.


Method 5 – Printing a Range of Cells using Excel VBA With Statement

You want to print Names, Ages, and Occupations of the first four persons.

Steps:

  • Enter the following code in the VBA Module. (To see how to open VBA Module, go to Method 1)
Sub PrintWithStatement()
With Sheets("With_Statement")
   .PageSetup.PrintArea = "B4:D8"
   .PrintOut
 End With
End Sub

excel vba print range of cellsThe With Statement defines the Excel sheet (With_Statement). The PrintArea property is used to print the selected range.

  • Go back to your sheet and run the Macro (PrintWithStatement).

To Save the file for further use or to Print it later:

  • The Save window will open. Save your range as PDF and rename it (Print by Statement, here).
  • Click Save.

excel vba print range of cells

  • Open the file to see the selected range.

To print it, press CTRL + P.


Practice Section

Practice here.

excel vba print range of cells


Download Practice Workbook


Related Articles

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Meraz Al Nahian
Meraz Al Nahian

Md. Meraz Al Nahian has worked with the ExcelDemy project for over 1.5 years. He wrote 140+ articles for ExcelDemy. He also solved a lot of user problems and worked on dashboards. He is interested in data analysis, advanced Excel, statistics, and dashboards. He also likes to explore various Excel and VBA applications. He completed his graduation in Electrical & Electronic Engineering from Bangladesh University of Engineering & Technology (BUET). He enjoys exploring Excel-related features to gain efficiency... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo