Hello,
I've copied a macro I've found on the excel help to protect multiple sheets in a worksheet which is working perfectly;
Sub Protect()
' Loop through all sheets in the workbook
For i = 1 To Sheets.Count
' Activate each sheet in turn.
Sheets(i).Activate
response = MsgBox("Do you want to protect this sheet?", vbYesNo)
If response = vbYes Then
ActiveSheet.Protect Password:="password", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End If
Next i
End Sub
I've now tried to create the same version to unprotect them all simply by changing the Protect to unprotect but it isn't working.
Sub Unprotect()
' Loop through all sheets in the workbook
For i = 1 To Sheets.Count
' Activate each sheet in turn.
Sheets(i).Activate
response = MsgBox("Do you want to unprotect this sheet?", vbYesNo)
If response = vbYes Then
ActiveSheet.Unprotect Password:="updates", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End If
Next i
End Sub
Can anybody help please, I love the fact these codes loop through all the spreadsheets. The debug highlights this section;
ActiveSheet.Unprotect Password:="updates", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
Thanks in advance for all your help