Printing every worksheet beyond a specific worksheet automatically

WxShady13

Board Regular
Joined
Jul 24, 2018
Messages
185
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have a workbook that contains numerous worksheets. I want to be able to have a macro that will automatically print every worksheet beyond the specific one when a button is clicked. Is this possible?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this:


Code:
Sub Print_Every_Worksheet()
    'Printing every worksheet beyond a specific worksheet automatically
    '
    hoja = InputBox("Write the name a specific worksheet", "PRINT SHEETS")
    If hoja = "" Then Exit Sub
    '
    For Each h In Sheets
        If LCase(h.Name) = LCase(hoja) Then
            n = h.Index
            Exit For
        End If
    Next
    If n = 0 Then
        MsgBox "There is no sheet with the name : " & hoja
        Exit Sub
    End If
    '
    For i = n To Sheets.Count
        Sheets(i).PrintOut
    Next
    MsgBox "End"
End Sub
 
Upvote 0
That works great, however it errors out after printing 14 worksheets. There are 4 more left to print out and are the same as the others. Any idea why it errors out after 14 and does not complete?
 
Upvote 0
That works great, however it errors out after printing 14 worksheets. There are 4 more left to print out and are the same as the others. Any idea why it errors out after 14 and does not complete?


What error message do you send?
And in which line of the macro does it stop?



Put the following instruction at the beginning of the macro and try again

Code:
On Error Resume Next
 
Upvote 0
Seriously thank you!!! This is tremendous and will be used daily!
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top