Question : Change tab color if tab name appears in list

This is the code i have to change the color of a tab if it appears in a list, it works fine for simple spreadsheets where the tabs are named a, b, c, d, and the like, but i have a workbook where the tab contains a number in parentheses after the value that will be in the list (tab will look like 123z4567-1 (1) and that value in the list will be 123z4567-1).  I only want the tab colored if it appears in this list, any help that you can offer?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Sub ColorTabs()
Dim TabName As String

x = 1

'Sheets("Pending List").Activate

Do Until Cells(x, 1).Value = ""

    TabName = Cells(x, 1).Value

    ActiveWorkbook.Sheets(TabName).Tab.ColorIndex = 4
    
    x = x + 1
    
Loop
        
End Sub

Answer : Change tab color if tab name appears in list

Sub ColorTabs()
Dim TabName As String

x = 1

'Sheets("Pending List").Activate
Do Until Cells(x, 1).Value = ""

  TabName = Cells(x, 1).Value

For Each Sheet In ActiveWorkbook.Sheets
If InStr(Sheet.Name, TabName) Then
 Sheet.Tab.ColorIndex = 4
End If
Next

  x = x + 1
 
Loop
End Sub


' to be exact
Random Solutions  
 
programming4us programming4us