• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Colour Tabs for Protected/Unprotected

Shazz

Member
I am using the below code that highlights my tabs green if protected and red if unprotected, I have a Summary tab that is also protected but I want this to show Yellow if Protected and red if unprotected.

Can anyone advise how I go about this please.


Code:
Private Sub Workbook_Open()

    Dim wbk As Workbook
    Dim ws As Worksheet

    Set wbk = ThisWorkbook

    For Each ws In wbk.Worksheets
        If ws.ProtectContents = True Then
            ws.Tab.Color = vbGreen
        Else
            ws.Tab.Color = vbRed
        End If
    Next

End Sub

Shazz
xx
 
Shazz
Something like this ...
Code:
Sub Tab_Colors()
    Application.ScreenUpdating = False
    For t = 1 To Worksheets.Count
        With Sheets(t)
            If .Name <> "Summary" Then
                bg = 3
                If .ProtectContents Then bg = 4
                .Tab.ColorIndex = bg
            End If
        End With
    Next t
    Application.ScreenUpdating = True
End Sub
 
v

On the attached, the Summary Tab is not colour Coding?, also can you take a look at the Holidays section on the Summary Sheet, they are not updating even though is shows it has been refreshed.

Shazz x
 

Attachments

  • Weekly Payroll Man & SB Hrs Test.xlsb
    564.3 KB · Views: 1
Sorry the Holidays Taken will not refresh when the protection is on, can this be changed at all?

and the Summary Tab is definitely not changing color.

Shazz x
 
Shazz
I understood that 'Summary'-tab color would be fixed - Yellow!
and
'Holidays Taken' ... as written ... wk-tab should have wk space and number
ex wk 6 has blank after 6 ... cannot work!

>> You should try that 'newer version' ... please <<
 

Attachments

  • Weekly Payroll Man & SB Hrs Test.xlsb
    563.6 KB · Views: 1
Sorry these are two different spreadsheets, I got myself confused lol.

The Summary Tab on my other project needs to be Yellow if Protected and Red if not protected.

Is this possible.

Shazz
 

Attachments

  • Calc Test.xlsm
    8.3 KB · Views: 1
vletm,

Sorry What I meant was I want all the tabs to show as Green when protected except the Summary which should be yellow, all tabs should be red when unprotected as well as the summary sheet.

Shazz
 
Back
Top