How to display all worksheets of a workbook in a listbox and then print a specific worksheet is based on a question from one of our YouTube channel subscribers:
“Comment on your video: Print specific worksheet from Excel Workbook ‘There any way, when you click print a window said, select sheet to print: on the window you see all names from de workbook and you just want to click it. Henri
Henri most probably means whether there is a way to display all the worksheets of a workbook and then select a worksheet from the list for printing.
We insert a userform and the userform we place a listbox control and a command button.
The listbox is populated with the sheetnames from the workbook by using a ‘do until’ loop as shown in the complete macro code below:
Private Sub UserForm_Initialize()
Dim n As Integer
n = n + 1
Loop Until n = Worksheets.Count
For printing a specific sheet we use a command button that is appropriately coded as shown below:
Private Sub CommandButton1_Click()
As you can see the VBA code for both the controls is not difficult to understand.
Watch the Excel VBA training video below to see how the complete process is implemented: