Excel VBA: Print Preview for Selected Range (5 Examples)

The article will show you some methods on how to print preview for selected range of cells in Excel by using Microsoft Visual Basic for Application (VBA). If you have a dataset that contains lots of information but you don’t want to print all of it, rather you want partial information of that dataset, you can use VBA effectively in that case. Before printing worksheets, it’s safe to check the print preview for the worksheets so that no errors remain and how they will look after printing. In the following dataset, we have information about several employees of Armani Group.

excel vba print preview selected range


Excel VBA to Show Print Preview for Selected Range (Quick View)

Sub Print_Range_Method()
Sheets("Range Method").Select
Range("B4:F9").Select
ActiveSheet.PageSetup.PrintArea = "B4:F9"
ActiveWindow.SelectedSheets.PrintOut From:=1, _
To:=1, Copies:=1, Collate:=True
End Sub

excel vba print preview selected range


Download Practice Workbook

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


5 Examples to Show Print Preview for Selected Range in Excel VBA

1. Apply Excel VBA PrintOut Method to Show Print Preview Selected Range

Now I’ll show how to print the preview selected range using a simple VBA code. It’s very helpful for some particular moments. From our dataset, we will print the preview selected range using a simple VBA code. Let’s follow the instructions below to print the preview selected range using a simple VBA code!

Step 1:

  • First of all, open a Module, to do that, firstly, from your Developer tab, go to,

Developer → Visual Basic

Apply Excel VBA PrintOut Method to Print Preview Selected Range

  • After clicking on the Visual Basic ribbon, a window named Microsoft Visual Basic for Applications – Print Preview Selected Range will instantly appear in front of you. From that window, we will insert a module for applying our VBA code. To do that, go to,

Insert → Module

Step 2:

  • Hence, the Print Preview Selected Range module pops up. In the Print Preview Selected Range module, write down the below VBA.
Sub Print_Preview_Selected_Range()
Range("B4:F15").PrintOut
End Sub

Apply Excel VBA PrintOut Method to Print Preview Selected Range

  • Hence, run the VBA To do that, go to,

Run → Run Sub/UserForm

Step 3:

  • After running the VBA Code, the Save window will appear. The range you chose, it will be saved as PDF if you choose PDF and in the given location of your drive. Give the PDF file a name. In this case, I named my file PrintOut.
  • Click Save.

Apply Excel VBA PrintOut Method to Print Preview Selected Range

  • After that, you can find the file in that location. Open it and you will see the range you have chosen.

  • You can see the print preview of this selected range of cells if you want by pressing CTRL + P and giving the necessary commands.

2. Defining the Excel Sheet to Show Print Preview Selected Range by Excel VBA

In this method, we will define the sheet name to print preview the selected range by Excel VBA. This is an easy and time-saving way also. Let’s follow the instructions below to print preview the selected range by Excel VBA!

Step 1:

  • First, according to method 1, insert a new module and type the below VBA code to multiply the cells. The VBA code is,
Sub Define_Sheet()
Sheets("Define Sheet").Range("B4:F10").PrintOut
End Sub

Defining the Excel Sheet to Print Preview Selected Range by Excel VBA

  • Further, run the VBA To do that, go to,

Run → Run Sub/UserForm

Step 2:

  • After running the VBA Code, the Save window will appear. The range you chose, it will be saved as PDF if you choose PDF and in the given location of your drive. Give the PDF file a name. In this case, I named my file Define Sheet.
  • Click Save.

Defining the Excel Sheet to Print Preview Selected Range by Excel VBA

  • After that, you can find the file in that location. Open it and you will see the range you have chosen.

Defining the Excel Sheet to Print Preview Selected Range by Excel VBA

  • You can see the print preview of this selected range of cells if you want by pressing CTRL + P and giving the necessary commands.

3. Use Print Preview Selected Range to Print by Excel VBA

Another way to print a range of cells by VBA is to select the range that we prefer to print preview. Suppose you want to print only the selected range of cells from our dataset. Let’s follow the instructions below to print preview the selected range by Excel VBA!

Step 1:

  • First, select a range of cells from our dataset. We will select the cells from B2 to F9 for the convenience of our work.

Use Print Preview Selected Range to Print by Excel VBA

  • After that, according to method 1, insert a new module and type the below VBA code to multiply the cells. The VBA code is,
Sub Selection_of_Print_Preview()
Range("B2:F9").PrintOut
End Sub

  • Further, run the VBA To do that, go to,

Run → Run Sub/UserForm

Use Print Preview Selected Range to Print by Excel VBA

Step 2:

  • After running the VBA Code, the Save window will appear. The range you chose, it will be saved as PDF if you choose PDF and in the given location of your drive. Give the PDF file a name. In this case, I named my file Selection.
  • Click Save.

  • After that, you can find the file in that location. Open it and you will see the range you have chosen.

Use Print Preview Selected Range to Print by Excel VBA

  • You can see the print preview of this selected range of cells if you want by pressing CTRL + P and giving the necessary commands.

4. Define Selected Range in the VBA Code to Show Print Preview Selected Range

We can also print a range of cells by VBA using the Range Method. Suppose you want to print the information about the first four persons. Let’s go through the procedure below!

Step 1:

  • First, according to method 1, insert a new module and type the below VBA code to multiply the cells. The VBA code is,
Sub Print_Range_Method()
Sheets("Range Method").Select
Range("B4:F9").Select
ActiveSheet.PageSetup.PrintArea = "B4:F9"
ActiveWindow.SelectedSheets.PrintOut From:=1, _
To:=1, Copies:=1, Collate:=True
End Sub

Define Selected Range in the VBA Code to Print Preview Selected Range

  • Hence, run the VBA To do that, go to,

Run → Run Sub/UserForm

Step 2:

  • After running the VBA Code, the Save window will appear. The range you chose, it will be saved as PDF if you choose PDF and in the given location of your drive. Give the PDF file a name. In this case, I named my file Range Method.
  • Click Save.

Define Selected Range in the VBA Code to Print Preview Selected Range

  • After that, you can find the file in that location. Open it and you will see the range you have chosen.

Define Selected Range in the VBA Code to Print Preview Selected Range

  • You can see the print preview of this selected range of cells if you want by pressing CTRL + P and giving the necessary commands.

5. Printing Preview Selected Range by Excel VBA With Statement

Last but not the least, VBA With Statement can play a vital role to print a range of cells. From our dataset, we will be able to print preview with statements in VBA code. Let’s follow the instructions below to learn!

Step 1:

  • First, according to method 1, insert a new module and type the below VBA code to multiply the cells. The VBA code is,
Sub Print_Preview_With_Statement()
With Sheets("Statement")
.PageSetup.PrintArea = "B4:F15"
.PrintOut
End With
End Sub

Printing Preview Selected Range by Excel VBA With Statement

  • Further, run the VBA To do that, go to,

Run → Run Sub/UserForm

Step 2:

  • After running the VBA Code, the Save window will appear. The range you chose, it will be saved as PDF if you choose PDF and in the given location of your drive. Give the PDF file a name. In this case, I named my file Statement.
  • Click Save.

Printing Preview Selected Range by Excel VBA With Statement

  • After that, you can find the file in that location. Open it and you will see the range you have chosen.

  • You can see the print preview of this selected range of cells if you want by pressing CTRL + P and giving the necessary commands.

Things to Remember

👉 You can also pop up Microsoft Visual Basic for Applications window by pressing Alt + F11 simultaneously on your keyboard.

👉 If a Developer tab is not visible in your ribbon, you can make it visible. To do that, go to,

File → Option → Customize Ribbon


Conclusion

I hope all of the suitable methods mentioned above to print preview selected range with VBA code will now provoke you to apply them in your Excel spreadsheets with more productivity. You are most welcome to feel free to comment if you have any questions or queries. Or, you can glance at our other articles in the ExcelDemy.com blog!

Md. Abdur Rahim Rasel

Md. Abdur Rahim Rasel

Hi! I'm Md. Abdur Rahim Rasel. Welcome to my Profile. Currently, I am working and doing research on Microsoft Excel and here I will be posting articles related to this. I have completed my graduation in Naval Architecture and Marine Engineering(NAME) from Bangladesh University of Engineering and Technology(BUET). I have a passion for learning new things with my knowledge through perseverance and hard work.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo