ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How recognize sheet protected? (https://www.excelbanter.com/excel-worksheet-functions/75219-how-recognize-sheet-protected.html)

John

How recognize sheet protected?
 
What code do I need in a macro to determine whether a sheet is protected or
not?

Paul B

How recognize sheet protected?
 
John, here is one way,

Sub Check__Sheet_Protection()
Dim wks As Worksheet
Set wks = ActiveSheet
With wks
If .ProtectContents _
Or .ProtectDrawingObjects _
Or .ProtectScenarios Then
MsgBox "Protected sheet"
Exit Sub
Else
MsgBox "Unprotected Sheet"
End If
End With
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"John" wrote in message
...
What code do I need in a macro to determine whether a sheet is protected
or
not?





All times are GMT +1. The time now is 10:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com