I have called the code below within a written macro. The code has caused some problems after protecting some hidden worksheets that require to be unprotected.
Could you help me by pointing me in the right direction/code so that I only protect the visible sheets in my workbook.
If you require more details please let me know.
Thanks in advance.
Steve
Sub ProtectSheets()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=" "
Else
wSheet.Protect Password:=" "
End If
Next wSheet
End Sub
Could you help me by pointing me in the right direction/code so that I only protect the visible sheets in my workbook.
If you require more details please let me know.
Thanks in advance.
Steve
Sub ProtectSheets()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=" "
Else
wSheet.Protect Password:=" "
End If
Next wSheet
End Sub