This procedure loops through each worksheet unhiding and unprotecting each one:
The intention of temporarily setting Application.DisplayAlerts to False was to stop the password dialog box from popping up. I would prefer that the procedure just continued, because in the event that some sheets are protected, the user is advised by the msgbox at the end.
Is there a way I can test whether a sheet is password protected, or
Is there a method of preventing the password box from displaying?
Code:
Sub unprotectunhideall()
Dim i As Integer
Dim noshts, areis As String
For Each sht In Worksheets
Application.DisplayAlerts = False
sht.Unprotect
Application.DisplayAlerts = True
If sht.ProtectContents = True Then i = i + 1
sht.Visible = True
Next sht
If i = 1 Then
noshts = " sheet "
areis = " is "
End If
If i > 1 Then
noshts = " sheets "
areis = " are "
End If
If i > 0 Then MsgBox (i & noshts & areis & "password protected.")
End Sub
The intention of temporarily setting Application.DisplayAlerts to False was to stop the password dialog box from popping up. I would prefer that the procedure just continued, because in the event that some sheets are protected, the user is advised by the msgbox at the end.
Is there a way I can test whether a sheet is password protected, or
Is there a method of preventing the password box from displaying?