tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,210
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have this macro that when run asks for a password then hides or unhides all purple tabs,
it works great but I only really need it to ask for a password if we are unhiding the sheets?
Can anyone edit or redo this macro so when run if the Purple tabs are visible it veryhides them but if they are hidden it asks for a passwrd then unhides them if the password is correct?
thanks
Tony
heres my code
I have this macro that when run asks for a password then hides or unhides all purple tabs,
it works great but I only really need it to ask for a password if we are unhiding the sheets?
Can anyone edit or redo this macro so when run if the Purple tabs are visible it veryhides them but if they are hidden it asks for a passwrd then unhides them if the password is correct?
thanks
Tony
heres my code
VBA Code:
Sub Hide_unhide_Purple_Sheets()
TABCOLOR2 = RGB(112, 48, 160) 'Purple
Dim ws As Object
Application.ScreenUpdating = False
x = InputBox("Enter Password", "")
If x = "august" Then
For Each ws In ActiveWorkbook.Worksheets
If ws.Tab.Color = TABCOLOR2 Then
If ws.Visible = xlSheetVisible Then
ws.Visible = xlSheetVeryHidden
Else
ws.Visible = xlSheetVisible
End If
End If
Next ws
Else
For Each ws In ActiveWorkbook.Worksheets
If ws.Tab.Color = TABCOLOR2 Then
ws.Visible = xlSheetVeryHidden
End If
Next ws
End If
NewReport1.Activate
Application.ScreenUpdating = True
End Sub