How to Display Print Preview in Excel: 3 VBA Macros

Method 1 – VBA Macro to Display Print Preview for the Active Sheet

  • Right-click on the sheet title.
  • Select View Code from the context menu.

A VBA window will appear. Or you can press Alt+F11 to open the VBA window directly.

VBA Macro to Display Print Preview for the Active Sheet

  • Type the following codes in it-
Sub PrintPreview_ActiveSheet()
ActiveSheet.PrintPreview
End Sub
  • Press the Run icon to run the codes, and consequently, you will get a Macros dialog box.

VBA Macro to Display Print Preview for the Active Sheet

  • Select the Macro Name as mentioned in the above codes.
  • Press Run.

VBA Macro to Display Print Preview for the Active Sheet

Print Preview window will open up.


Method 2 – VBA Macro to Display Print Preview for Specific Worksheet in Excel

  • Open the VBA window by selecting View Code from the context menu after right-clicking on the sheet title.

VBA Macro to Display Print Preview for Specific Worksheet in Excel

  • Write the following codes in the VBA window-
Sub PrintPreview_SpecificSheet()
Worksheets("Specific Sheet").PrintPreview
End Sub
  • Press the Run icon and the Macros dialog box will appear.

VBA Macro to Display Print Preview for Specific Worksheet in Excel

  • Select the specified Macro Name from the dialog box.
  • Press Run.

VBA Macro to Display Print Preview for Specific Worksheet in Excel

You will get the Print Preview window like the image below.


Method 3 – VBA Macro to Display Print Preview for the Selected Worksheets

  • Open the VBA window for this sheet, like the previous methods.

VBA Macro to Display Print Preview for the Selected Worksheets

  • Write the following codes in the VBA window-
Sub PrintPreview_SelectedSheets()
ActiveWindow.SelectedSheets.PrintPreview
End Sub
  • Press the Run icon to run the codes and open the Macros dialog box.

VBA Macro to Display Print Preview for the Selected Worksheets

  • Select the Macro Name as mentioned in the above codes, and then just press Run.

VBA Macro to Display Print Preview for the Selected Worksheets

Soon after you will get the print preview for the currently selected sheet only.

VBA Macro to Display Print Preview for the Selected Worksheets

  • Get the print preview for multiple sheets, close the preview and minimize the VBA window, go back to your workbook, and select the multiple sheets using your mouse by pressing and holding the Ctrl key on your keyboard.

VBA Macro to Display Print Preview for the Selected Worksheets

  • Go to that VBA window and run the codes by clicking the Run icon.

VBA Macro to Display Print Preview for the Selected Worksheets

  • Select the same Macro Name again.

  • The Print Preview window shows the preview of the first worksheet. To see the other previews just press Next Page.

It’s the preview of another worksheet.


Things to Remember

  • The VBA operations can be operatable after making Macros for the source data.
  • Make sure there are no spaces between the functions.
  • VBA function can directly be accessed by Alt+F11.
  • Make sure that you have clicked the same worksheet whose Print Preview you want before typing the Activesheet function in the VBA window.

Download Practice Workbook

You can download the free Excel template from here and practice on your own.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Md. Sourov Hossain Mithun
Md. Sourov Hossain Mithun

Md. Sourov Hossain Mithun, an Excel and VBA Content Developer at Softeko's ExcelDemy project, joined in October 2021. Holding a Naval Architecture & Marine Engineering degree from BUET, Mithun showcases expertise during his two-year tenure. With over 200 published articles on Excel topics, he earned a promotion to Team Leader, excelling in leading diverse teams. Mithun's passion extends to Advanced Excel, Excel VBA, Data Analysis, and Python programming, contributing significantly to the innovative and dynamic environment of ExcelDemy... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo