How to get all available sheets except for some specific ones

Viewed 19

I want to create the code to be getting all sheets in my workbook except for 2 specific ones. It would be something like I have 17 sheets that I want to parse and 2 extra sheets that I want exclude them by name that I don't need to parse. I tried this code but it deletes the unwanted sheets while what I need is to remove them from the list that I will then use to loop to parse the remaining correct sheets:

Sub Print_all_sheet_names()

' Declare ws as a worksheet object variable.
Dim ws As Worksheet

ThisWorkbook.Sheets("Qlik Ingestion").Delete
ThisWorkbook.Sheets("Dropdown Values").Delete

' Loop through all of the worksheets in the active workbook.
For Each ws In ThisWorkbook.Worksheets
    
   MsgBox ws.Name
Next
End Sub

Anybody knows how I can be left in the list only with the wanted sheets without deleting the unwanted ones?

1 Answers

Loop through all the sheets and check their names

For Each ws In ThisWorkbook.Worksheets
    Select Case ws.Name
        Case "Qlik Ingestion"
            'Do nothing
        Case "Dropdown Values"
            'Do nothing
        Case Else
             MsgBox ws.Name
    End Select
Next
Related