Link to home
Start Free TrialLog in
Avatar of Geekamo
GeekamoFlag for United States of America

asked on

Unprotect Worksheet in VBA

Hello Experts,

I have this code on my workbook:

Sub EmployeesShowAndHideColumns()
Columns(EmpToggleCol).Hidden = Columns(EmpToggleCol).Hidden = False
End Sub

Sub TeamLeadShowAndHideColumns()
Columns(TLToggleCol).Hidden = Columns(TLToggleCol).Hidden = False
End Sub

Sub PhoneTimeShowAndHideColumns()
Columns(PTToggleCol).Hidden = Columns(PTToggleCol).Hidden = False
End Sub

Open in new window


I only have problem with this code running when the worksheet is locked.  Is there a line of code that could be interested after the sub starts, and before it finishes to unprotect/protect the worksheet?

Thank you in advance for your help!
ASKER CERTIFIED SOLUTION
Avatar of Flyster
Flyster
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Geekamo

ASKER

@ Flyster - What do I do, if I don't use a password?
Avatar of Geekamo

ASKER

@ Flyster - I guess I answered my own question. :)  I just left the password part off of your solution.  Thanks Flyster! :)
I should have mentioned that in my original post. Glad it worked for you. Thanks.