So I have a workbook with 100+ sheets. The sheets are protected and use either one of two different passwords.
I need a way to unprotect all of the sheets cycling through the two different passwords if one or the other fail to unprotect the worksheet.
I don't know which sheets are using which password.
The Passwords are: Test1 & 1Test
I have been using the following code in previous projects to unprotect worksheets, but in those cases there was only one password being used.
The issue I have is that when I try to use the above, if the password is anything other than Test1, it fails, for obvious reasons.
How can I unprotect a worksheet, and if Test1 fails to unprotect it, then have it unprotect with 1Test??
Something like this:
Granted, I know that the above isn't really how the code should be written, but at least it gives an idea of what I am looking for.
Any thoughts, ideas, suggestions?
Thanks in advance!
I need a way to unprotect all of the sheets cycling through the two different passwords if one or the other fail to unprotect the worksheet.
I don't know which sheets are using which password.
The Passwords are: Test1 & 1Test
I have been using the following code in previous projects to unprotect worksheets, but in those cases there was only one password being used.
Code:
[COLOR=#333333]Sub UnProtectSheets()[/COLOR]
[COLOR=#333333]Dim ws As Worksheet[/COLOR]
[COLOR=#333333]For Each ws In ActiveWorkbook.Worksheets[/COLOR]
[COLOR=#333333]ws.Unprotect password:="Test1"[/COLOR]
[COLOR=#333333]Next ws[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
The issue I have is that when I try to use the above, if the password is anything other than Test1, it fails, for obvious reasons.
How can I unprotect a worksheet, and if Test1 fails to unprotect it, then have it unprotect with 1Test??
Something like this:
Code:
[COLOR=#333333]Public Sub DeProtectAll()[/COLOR]
[COLOR=#333333]Dim ws As Worksheet[/COLOR]
[COLOR=#333333]For Each ws In ActiveWorkbook.Worksheets[/COLOR]
[COLOR=#333333]If ws.Unprotect password:="Pass" Fails Then
[/COLOR] ws.Unprotect password:="1Test"
End If
[COLOR=#333333]Next ws[/COLOR]
[COLOR=#333333]End Sub
[/COLOR]
Granted, I know that the above isn't really how the code should be written, but at least it gives an idea of what I am looking for.
Any thoughts, ideas, suggestions?
Thanks in advance!