+ Reply to Thread
Results 1 to 4 of 4

Excel: Print all sheets excluding certain tabs using a wildcard (*)

  1. #1
    Registered User
    Join Date
    01-10-2018
    Location
    USA
    MS-Off Ver
    10
    Posts
    17

    Excel: Print all sheets excluding certain tabs using a wildcard (*)

    I have this code that works if the tab I want to exclude is standard through out all the documents I am trying to print. However, instead of a specific name of the tab, I would like to use a wildcard (*) to find that reference to exclude from printing.
    ShtName = Array("Revision History")
    I have tried using ("*Rev*") but didn't work, any suggestions?


    Here is the code:
    Sub PrintAllWorkbooks()
    'Step 1:Declare your variables
    Dim MyFiles As String
    'Step 2: Specify a target folder/directory
    MyFiles = Dir("mylink\*.xls*")
    Do While MyFiles <> ""
    'Step 3: Open Workbooks one by one
    Workbooks.Open "\\us108fp00\data\Krshare\QIP conversions\PrintQIPTempFile\" & MyFiles
    'ActiveWorkbook.Sheets("Sheet1").PrintOut Copies:=1

    Dim sht
    Dim ShtName
    ShtName = Array("Revision History")
    For I = 1 To Worksheets.Count
    For J = 0 To UBound(ShtName)
    If Worksheets(I).Name = ShtName(J) Then Count = 1
    Next J
    If Count = 0 Then Worksheets(I).PrintOut copies:=1
    Count = 0
    Next I



    ActiveWorkbook.Close SaveChanges:=False

    'Step 4: Next File in the Directory
    MyFiles = Dir
    Loop
    End Sub

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Excel: Print all sheets excluding certain tabs using a wildcard (*)

    You could change your code with '=' with 'like':
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    01-10-2018
    Location
    USA
    MS-Off Ver
    10
    Posts
    17

    Re: Excel: Print all sheets excluding certain tabs using a wildcard (*)

    perfect, thank you
    Last edited by kalyan46; 07-18-2018 at 01:46 PM.

  4. #4
    Registered User
    Join Date
    01-10-2018
    Location
    USA
    MS-Off Ver
    10
    Posts
    17

    Re: Excel: Print all sheets excluding certain tabs using a wildcard (*)

    now that this code work perfectly, is there a way to print the files from a list in a sequence order instead of just printing the folder? Example: the folder that is on a loop prints based on numerical value, I would like to print the files out based upon my list to create those files. FOLDER: files might be in order like: 10.xlsx, 11.xlsx, 12.xlsx... My order based on my sequence list file might be:

    ColA ColB
    PN Seq#
    11 1
    10 2
    12 3

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to Print to PDF the tabs between two tabs by click of button
    By sherryaw in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-13-2016, 02:13 PM
  2. VBA code to print pdf different tabs in excel worksheet
    By satsyie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-05-2014, 11:02 PM
  3. VBA code to print pdf different tabs in excel worksheet
    By satsyie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2014, 11:15 PM
  4. Find Print Range and Print invoices from 250 tabs in Excel
    By Mr5holesinone in forum Excel General
    Replies: 4
    Last Post: 02-24-2014, 08:19 PM
  5. Replies: 0
    Last Post: 12-18-2011, 10:10 AM
  6. Print visible sheets excluding certain ones
    By amelio in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2011, 12:17 PM
  7. [SOLVED] How do I print out a list of the tabs in an Excel workbook?
    By Britomart in forum Excel General
    Replies: 3
    Last Post: 01-09-2006, 02:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1