jimbofoxman
New Member
- Joined
- Feb 23, 2018
- Messages
- 13
So I found lots of references to this kinda code for locking all sheets at once.
While it does lock all sheets, it doesn't lock them all the same. If I were to lock a sheet from the ribbon "Protect Sheet" button, the only two boxes I have checked are "Protect worksheet and contents of locked cells" and "Select Unlocked cells" from the lower check box list.
Then the user can only select and type the fields I have unlocked. They cannot select locked fields, say a formula cell.
When I use the macro, it locks the first page like above but all the rest of the sheets any cell can be selected. But even though any cell can be selected if it's locked they cannot change it..........so essentially it still is locked. A message pops up say You cannot change the cell as it's protected, blah blah blah. So it's locked.
It may be trivial, but I'd like it to lock all sheets like the first one, where only unlocked cells can be selected. I tried adding "Contents:=True" to the wSheet.Protect line but that didn't do anything to help.
Is their anything that can be done? Or is it just one of the downfalls of locking multiple sheets at once with code? In this case, probably 90 sheets.
Thanks,
Jim
Code:
Sub ProtectAll()
Dim wSheet As Worksheet
Dim Pwd As String
Pwd = InputBox("Enter your password to protect all worksheets", "Password Input")
For Each wSheet In Worksheets
wSheet.Protect Password:=Pwd
Next wSheet
End Sub
While it does lock all sheets, it doesn't lock them all the same. If I were to lock a sheet from the ribbon "Protect Sheet" button, the only two boxes I have checked are "Protect worksheet and contents of locked cells" and "Select Unlocked cells" from the lower check box list.
Then the user can only select and type the fields I have unlocked. They cannot select locked fields, say a formula cell.
When I use the macro, it locks the first page like above but all the rest of the sheets any cell can be selected. But even though any cell can be selected if it's locked they cannot change it..........so essentially it still is locked. A message pops up say You cannot change the cell as it's protected, blah blah blah. So it's locked.
It may be trivial, but I'd like it to lock all sheets like the first one, where only unlocked cells can be selected. I tried adding "Contents:=True" to the wSheet.Protect line but that didn't do anything to help.
Is their anything that can be done? Or is it just one of the downfalls of locking multiple sheets at once with code? In this case, probably 90 sheets.
Thanks,
Jim