![]() |
How to detect protected sheet
How do I detect whther a sheet is protected or not? I need the sheet
unprotected for the subroutine, but I need to know whether it was already unprotected so I can leave it in the same satte after the sub runs. -- Ian -- |
How to detect protected sheet
Do it the type of item being protected:
Sub dural() Dim s As Worksheet Dim t As Boolean Set s = ActiveSheet t = s.ProtectContents MsgBox (t) End Sub -- Gary''s Student - gsnu200905 "IanC" wrote: How do I detect whther a sheet is protected or not? I need the sheet unprotected for the subroutine, but I need to know whether it was already unprotected so I can leave it in the same satte after the sub runs. -- Ian -- |
How to detect protected sheet
Directly from VBA help on ProtectContents Property
If Worksheets("Sheet1").ProtectContents = True Then MsgBox "The contents of Sheet1 are protected." End If Gord Dibben MS Excel MVP On Tue, 29 Sep 2009 17:15:31 +0100, "IanC" wrote: How do I detect whther a sheet is protected or not? I need the sheet unprotected for the subroutine, but I need to know whether it was already unprotected so I can leave it in the same satte after the sub runs. -- Ian |
How to detect protected sheet
Thanks. I'd tried the ProtectionMode property and couldn't get it to work.
Your solution is just what I needed. -- Ian -- "Gary''s Student" wrote in message ... Do it the type of item being protected: Sub dural() Dim s As Worksheet Dim t As Boolean Set s = ActiveSheet t = s.ProtectContents MsgBox (t) End Sub -- Gary''s Student - gsnu200905 "IanC" wrote: How do I detect whther a sheet is protected or not? I need the sheet unprotected for the subroutine, but I need to know whether it was already unprotected so I can leave it in the same satte after the sub runs. -- Ian -- |
How to detect protected sheet
"Gord Dibben" <gorddibbATshawDOTca wrote in message ... Directly from VBA help on ProtectContents Property If Worksheets("Sheet1").ProtectContents = True Then MsgBox "The contents of Sheet1 are protected." End If Thanks Gord. I looked at this after Gary's Student pointed me this way. It's easy when you know what keywords to look for. I'd searched for "Protect" and ProtectionMode sounded the most likely.... .....but wasn't -- Ian -- |
All times are GMT +1. The time now is 09:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com