Auto color a tab

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
Can you auto color a tab based on the tab name?
If the Tab name starts with "A_EOIS" Light Blue
If the Tab name starts with "X_EOIS" Dark Blue
If the Tab name starts with "A_DLE_" Light green
If the Tab name starts with "X_DLE_" Dark green


Anything else leave as is

Is this possible?

Thanks for the help

PS I have code that changes the tab name on change
Code:
Private Sub Worksheet_change(ByVal Target As Range)
If Not Intersect(Target, Range("O1,E10,E2")) Is Nothing Then
    Dim shName As String, ws As Worksheet
        shName = Range("R1")
    On Error Resume Next
        Set ws = Worksheets(shName)
    If Not ws.Name = shName Then
        If shName <> "__" And LCase(Me.Name) <> "template" Then Me.Name = shName
    End If
    On Error GoTo 0
End If

Dim cursht As String
cursht = ActiveSheet.Name
   If cursht <> "Template" Then
     Me.Protect Password:="Password"
   Else
      Sheet5.Visible = False
   End If
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You can do that like
VBA Code:
    If Not Ws.Name = shname Then
        If shname <> "__" And LCase(Me.Name) <> "template" Then
            Me.Name = shname
            Select Case Left(shname, 6)
               Case "A_EOIS": Me.Tab.ColorIndex = 20
               Case "X_EOIS": Me.Tab.ColorIndex = 5
            End Select
        End If
    End If
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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