Print and export sheets by common tab name

Dunk4Divin

New Member
Joined
Aug 21, 2019
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a workbook which currently has 60+ sheets. Some of these are generated by copying the format from a "master" form and creating a series of work instructions for which the Tabs are named "Gauge Instruction (X)". The suffix is the normal excel generated number. What I need to be able to do is select all sheets with the words "Gauge Instruction" without the suffix and then:

1 Print hard copies
2 Export to a new workbook
3 Export as PDFs.

Any assistance will be greatly appreciated.

Thanks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
VBA Code:
Sub ExportAll()
    Dim wsWS As Worksheet
    Dim wbWB As Workbook, wbThis As Workbook
    Dim sIncl As String, sFind As String
    
    sIncl = "Gauge Instruction" ' Name (excl order number) of all sheets to process
    
    
    Set wbThis = ThisWorkbook
    
    sFind = sIncl & "*"         ' add search asterix
    
    For Each wsWS In ThisWorkbook.Sheets
        If wsWS.Name Like sFind Then
            ' sheet found
            ' make a copy to new workbook
            wsWS.Copy
            Set wbWB = ActiveWorkbook
            wbWB.SaveAs Filename:=wsWS.Name
            wbWB.Close
            ' print as pdf
            wsWS.ExportAsFixedFormat _
                Type:=xlTypePDF, _
                Filename:="C:\TestFolder\temp.pdf", _
                Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, _
                IgnorePrintAreas:=False, _
                OpenAfterPublish:=True
            ' print to printer
            wsWS.PrintOut
        End If
    Next wsWS
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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