Printing Problems

Choose a Printer Before Printing Excel Cells with VBA

Anum MushtaqAnum Mushtaq Nov 22, 2026 868 views

Question details

The user wants an Excel VBA macro to let them choose a printer before printing a cell range.

Choose a Printer Before Printing Excel Cells with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A macro prints cells B1:J67, but the user wants to select the printer first.
Observed behavior
The existing PrintOut command prints without first asking the user to choose a printer.
Before you start

Open the workbook in a version of Excel that supports VBA and make sure the desired printer is available to Excel. Identify the worksheet and range you want the macro to print.

Solution 1Recommended

Show Printer Setup Before Printing the Excel Range

Use Excel's printer setup dialog to choose the active printer, then print the specified cells.

The dialog returns False if the user cancels. The example exits in that case so the macro does not print unexpectedly.

1
Open the VBA editor

In Excel, open the Developer tab and select Visual Basic. In the editor, open the module containing your macro or choose Insert > Module.

2
Add the printer dialog

Replace or update your macro with this code: Sub PrintSomeCells() Dim bChoice As Boolean bChoice = Application.Dialogs(xlDialogPrinterSetup).Show(ActivePrinter) If Not bChoice Then Exit Sub Application.Calculate ActiveSheet.Range("B1:J67").PrintOut End Sub

3
Choose a printer and print

Activate the worksheet to print, then run PrintSomeCells from Developer > Macros. Choose a printer in the setup dialog and confirm; the macro calculates and prints B1:J67 on that printer.

Show Printer Setup Before Printing the Excel Range
Adjust the range: Change B1:J67 to the cells you need. ActiveSheet refers to the worksheet active when the macro runs.
Free Microsoft Office alternative

Print Spreadsheet Ranges with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with and printing spreadsheets. Its Microsoft Office format compatibility helps you move existing files to WPS, although it does not fix Excel's VBA behavior.

Select and print spreadsheet cells through the print interfaceOpen and edit Microsoft Excel XLSX filesFamiliar spreadsheet controls make migration easierFree and lightweight office suite
QA img-9

Frequently Asked Questions

What happens if I cancel the printer setup dialog?

In the example, Show returns False and the If Not bChoice Then Exit Sub line stops the macro before PrintOut.

How do I print a different range?

In the VBA editor, change ActiveSheet.Range("B1:J67") to the range you need, such as ActiveSheet.Range("A1:D20").

Does the macro print from a specific worksheet?

The example uses ActiveSheet, so it prints from the worksheet active when the macro runs. Replace ActiveSheet with a worksheet reference such as Worksheets("Sheet1") to target a named sheet.

Why does the macro calculate before printing?

Application.Calculate recalculates open workbooks before PrintOut. You can remove that line if recalculation is not needed.