![]() |
Return boolean if sheet is currently protected
I want to Create a simple Sub that protects the sheet if it is not currently
protected, and unprotects the sheet if it is protected... i.e. Sub SheetProtect () If ActiveSheet.Protect = true then ActiveSheet.Unprotect Else ActiveSheet.Protect End If End Sub The part that I need help with is obviously the "If" argument. Any help would be appreciative. |
Return boolean if sheet is currently protected
Hi Mike,
Try this With ActiveSheet If Not .ProtectContents Then .Protect Else .Unprotect End If End With -- HTH RP (remove nothere from the email address if mailing direct) "Mike" wrote in message ... I want to Create a simple Sub that protects the sheet if it is not currently protected, and unprotects the sheet if it is protected... i.e. Sub SheetProtect () If ActiveSheet.Protect = true then ActiveSheet.Unprotect Else ActiveSheet.Protect End If End Sub The part that I need help with is obviously the "If" argument. Any help would be appreciative. |
Return boolean if sheet is currently protected
Thanks much.
"Bob Phillips" wrote: Hi Mike, Try this With ActiveSheet If Not .ProtectContents Then .Protect Else .Unprotect End If End With -- HTH RP (remove nothere from the email address if mailing direct) "Mike" wrote in message ... I want to Create a simple Sub that protects the sheet if it is not currently protected, and unprotects the sheet if it is protected... i.e. Sub SheetProtect () If ActiveSheet.Protect = true then ActiveSheet.Unprotect Else ActiveSheet.Protect End If End Sub The part that I need help with is obviously the "If" argument. Any help would be appreciative. |
All times are GMT +1. The time now is 09:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com