How to Print Specific Worksheet from Multiple Worksheets in Workbook Using VBA

An interesting and practical question on using Excel VBA to print a specific worksheet from multiple worksheets in a workbook:
‘How can I create a macro that can print a specific sheet; my book has 35 sheets; I need something like a window to come up asking what sheet I want to print. Thanks’

We first create a command button so that user can start working with a single click. Then, Because the user wants to enter a sheet number from a pop-up window, we create an inputbox in our VBA or macro code. The value that the user enters in the inputbox is assigned to a variable called myNum. Next we use the worksheets object and assign the index number to it using the value assigned to myNum. Finally we use the ‘printout’ function to print the worksheet.
The macro or VBA code that can be used with numbered worksheets is given below for your ready reference:
Private Sub CommandButton1_Click()
Dim myNum As Integer
myNum = Application.InputBox(“Enter a sheet number”)
End Sub

For named sheets we can use the following Excel VBA code:
Private Sub CommandButton1_Click()
Dim sheetname As String
sheetname = Application.InputBox(“Enter a sheet name”)
End Sub
Watch the Excel training video to see how this interesting VBA solution for printing a specific numbered or named worksheet from multiple worksheets in an Excel workbook is implemented:

5 thoughts on “How to Print Specific Worksheet from Multiple Worksheets in Workbook Using VBA

  1. chander shekhar

    how to print specific hided worksheet with command button without making them unhided..please give me a vba code if you have answer in this problem aqnd

  2. Karl

    How would you do this exact same thing but instead of printing the sheets slected, it exports the sheet to PDF and places the saved file on the desktop?

  3. Taylor

    Hi there!I have discovered that with Photoshop there are a miiloln and a half ways to do the same thing. When I read the title for this tutorial I was hoping to get some secrets about the brush settings. As it turns out your technique doesn’t change the brush settings except for hard/soft edge.You can achieve smooth shading by reducing the Flow to around 5% and reducing the opacity to 18 30%. Then it layers on much the same way graphite on paper does. The more strokes you add, the darker it gets and you don’t get the marker effect of messy translucent strokes overlapping each other.However, even though I have been using Photoshop since version 4 (back in 1995) I didn’t know to use painting techniques the way you do, or the use of clipping mask and nested masks.So an old dog can learn new tricks

  4. Ron

    This is great stuff, however I’m still stuck on why it prints a blank sheet afterwards and then on some computers (most every one except on the computer where the file was created) it will only print one blank page


Leave a Reply

Your email address will not be published. Required fields are marked *