
This will facilitate us with the preview layout of the print area before printing. To use the PrintPreview method, we just need to replace the. PrintOut method to enable the print option in our code. We could also use the Sheets.PrintPreview method instead of the Sheets. Read More: Excel VBA: Set Print Area for Multiple Ranges (5 Examples) It selected the predefined range B2:G7 in Sheet1. Range("B2:G7").AddressĬlick the name box and then select the named range “Print_Area”.

We defined the range B2:G7 in our VBA code to set the print area for selection.
#Vba print selection how to
In this illustration, we’ll see how to define a range hardcoded in the VBA code to set the print area for selection. Run a VBA Code to Set Print Area to Selection with a Pre-Defined Range in Excel Print Excel Sheet with Lines (3 Easy Ways)ģ.How to Print Excel Spreadsheet on Multiple Pages (3 Ways).
#Vba print selection full
#Vba print selection pdf
If we run the code, it’ll open up a window to save the print area as a pdf in our computer’s storage. To print the selected print area, we need to add the Sheets.PrintOut method in our code. Now, click and select the “ Print_Area” named range. Sub PrintAreaToSelection()Ĭlick the namebox, there is a named range as “Print_Area”. We selected range B2:G5 to set the print area for selection.Ĭopy and paste the following code and press F5 to run it. In this example, we’ll set the print area for selection based on the current region i.e., the active selected range of the dataset. Set Print Area to Selection with Current Region Using VBA in Excel

Now put your code inside the visual code editor and press F5 to run it.ġ.
