Roy_Excel_Island_Apps
Board Regular
- Joined
- Oct 9, 2018
- Messages
- 68
- Office Version
- 365
- Platform
- Windows
Hi guys!
So I have this code to loop through all sheets and protect them with a public const "pw":
Public Sub ProtectStructure()
ThisWorkbook.Protect pw, True, False
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
Debug.Print sht.Name
sht.Protect pw, , , , True, , , , , , , , , True, True, True
Next sht
End Sub
After running this code all sheets are protected, but only the first 4 sheets are protected WITH the password!? What's the issue here? Workbook corrupt? I can't find a reason why the code would stop using the password in the protection after using is 4 times... Anyone who has an idea?
Regards, Roy
So I have this code to loop through all sheets and protect them with a public const "pw":
Public Sub ProtectStructure()
ThisWorkbook.Protect pw, True, False
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
Debug.Print sht.Name
sht.Protect pw, , , , True, , , , , , , , , True, True, True
Next sht
End Sub
After running this code all sheets are protected, but only the first 4 sheets are protected WITH the password!? What's the issue here? Workbook corrupt? I can't find a reason why the code would stop using the password in the protection after using is 4 times... Anyone who has an idea?
Regards, Roy