I have been using the following code that someone sent me for years to help with protecting / unprotecting all sheets within a workbook. When I attempt to run this Macro in Excel 2019, it fails with an error of: "Cannot find project or library". Were there changes within Excel 2019 that are causing this?
Sub protect_all_sheets() top: pass = InputBox("Key in Desired Password?") repass = InputBox("Please Verify Password") If Not (pass = repass) Then MsgBox "Please Enter Password" GoTo top End If For i = 1 To Worksheets.Count If Worksheets(i).ProtectContents = True Then GoTo oops Next For Each s In ActiveWorkbook.Worksheets s.Protect Password:=pass Next Exit Sub oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro." End Sub Sub unprotect_all_sheets() On Error GoTo booboo unpass = InputBox("Key in Password") For Each Worksheet In ActiveWorkbook.Worksheets Worksheet.Unprotect Password:=unpass Next Exit Sub booboo: MsgBox "There is s problem - check your password, capslock, etc." End Sub
Last edited by a moderator: