Forum Discussion

Jon_Morgan1958's avatar
Jon_Morgan1958
Copper Contributor
Sep 24, 2023
Solved

Select Worksheets by Tab Colour

Hi.  I need some help please?  My file is organised by WSheet Tab Colour.  I need to be able to select all by Tab Colour or some other criteria.  Alternately by some other method such as creating a list and then selecting that list to loop thru.

 

Any help much appreciated.

 

Regards

Jon

  • Jon_Morgan1958 

    Perhaps something like this?

    Sub Test()
        LoopTabColor Color:=vbYellow
    End Sub
    
    Sub LoopTabColor(Color As Long)
        Dim wsh As Worksheet
        For Each wsh In Worksheets
            If wsh.Tab.Color = Color Then
                ' Do something with this sheet
                Debug.Print wsh.Name
            End If
        Next wsh
    End Sub

2 Replies

  • Jon_Morgan1958 

    Perhaps something like this?

    Sub Test()
        LoopTabColor Color:=vbYellow
    End Sub
    
    Sub LoopTabColor(Color As Long)
        Dim wsh As Worksheet
        For Each wsh In Worksheets
            If wsh.Tab.Color = Color Then
                ' Do something with this sheet
                Debug.Print wsh.Name
            End If
        Next wsh
    End Sub

Resources