ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically determining if worksheet is protected (https://www.excelbanter.com/excel-programming/377151-programmatically-determining-if-worksheet-protected.html)

Barb Reinhardt

Programmatically determining if worksheet is protected
 
How would I check to see if the activesheet is protected? I know how to
protect and unprotect programmatically, but only want to unprotect it if it's
already protected.

Thanks

Bob Phillips

Programmatically determining if worksheet is protected
 
If Worksheets("Sheet1").ProtectContents = True Then
MsgBox "The contents of Sheet1 are protected."
End If
--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Barb Reinhardt" wrote in message
...
How would I check to see if the activesheet is protected? I know how to
protect and unprotect programmatically, but only want to unprotect it if

it's
already protected.

Thanks




Jim Thomlinson

Programmatically determining if worksheet is protected
 
It is not really worth checking. Just run the unprotect. You can however
check to see if it is protected something like this...

dim wks as worksheet

for each wks in worksheets
if wks.protectcontents = true then wks.unprotect
next wks
--
HTH...

Jim Thomlinson


"Barb Reinhardt" wrote:

How would I check to see if the activesheet is protected? I know how to
protect and unprotect programmatically, but only want to unprotect it if it's
already protected.

Thanks



All times are GMT +1. The time now is 02:07 PM.

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