May 27, 2022

Print Selected Range

How to select a range and print it automatically using a macro. Watch the video below:

How to print a selected range using a macro

Whenever a user selects the print command, the whole sheet is printed. If we press Ctrl + P to print then we have to perform a manual selection as shown in the image below:

Print using Ctrl + P

For quick printing we can add the option ‘Quick Print’ to our Quick Access Toolbar (QAT) as shown in the image below:

Add Quick Print to Quick Access Toolbar (QAT)

However, even Quick Print will print the whole sheet and we will have to specify a few steps to print the selected range.

To have a great way to print only the selected data, we could write this useful macro:

Sub PrintSelectedData
Selection.Printout Copies:=1, Collate:=True
End Sub

We have modified the above simple macro to learn some more interesting code as shown in the video above:

Sub PrintMyData()
Dim MyData As Range
On Error Resume Next
Set MyData = Application.InputBox(prompt:=”Select Range”, Type:=8)
If MyData Is Nothing Then Exit Sub
‘MyData.PrintOut copies:=1, collate:=True
End Sub

If we wish to print all cells with data then we can use the following macro code:

Sub PrintSelectedData
End Sub