ADAMC
Well-known Member
- Joined
- Mar 20, 2007
- Messages
- 1,169
- Office Version
- 2013
- Platform
- Windows
Hi all,
I have a rough idea of what I want but my structure is confusing me big time
Mixing if/ then/ else with For each/ next aaaaaaarghhhhhhhh
what i want to do:
IF username is "me" unlock every sheet in the workbook and show a msgbox
if its anyone but me leave it as is and just open it
what I have
Can someone help me with the unprtect all worksheets bit?
I was along the lines of:
but couldnt seem to incorporate the 2 together.
On the workbook close event again id need to re test to say if being closed by the admin re - protect all worksheets again.......
Thanks
I have a rough idea of what I want but my structure is confusing me big time
Mixing if/ then/ else with For each/ next aaaaaaarghhhhhhhh
what i want to do:
IF username is "me" unlock every sheet in the workbook and show a msgbox
if its anyone but me leave it as is and just open it
what I have
Code:
Private Sub Workbook_Open()
If Environ("Username") = "EMPLOYEENAME" Then
'Unlock all the worksheets
MsgBox "Logged in as an admin worksheet fully accessible"
Else
'Just open as normal with sheet protection active
End If
End Sub
Can someone help me with the unprtect all worksheets bit?
I was along the lines of:
Code:
For Each wSheet In Worksheets
wSheet.Unprotect Password:= ""
Next wSheet
but couldnt seem to incorporate the 2 together.
On the workbook close event again id need to re test to say if being closed by the admin re - protect all worksheets again.......
Thanks