PC Review


Reply
Thread Tools Rate Thread

Cell to indicate protected sheet

 
 
Jim
Guest
Posts: n/a
 
      17th Feb 2008
Is there any way that a cell can be set up to indicate if a sheet is
protected or unprotected?

Thanks
 
Reply With Quote
 
 
 
 
Ken Johnson
Guest
Posts: n/a
 
      17th Feb 2008
On Feb 17, 9:54 pm, Jim <sylv1...@yahoo.com> wrote:
> Is there any way that a cell can be set up to indicate if a sheet is
> protected or unprotected?
>
> Thanks


Do you mean something like this?
A1 would have to be locked.

Public Sub CheckProtection()
On Error GoTo PROTECTED
Range("A1").Value = "Not Protected"
Exit Sub
PROTECTED: ActiveSheet.Unprotect: Range("A1").Value = "Protected"
ActiveSheet.Protect
End Sub

Ken Johnson
 
Reply With Quote
 
SteveM
Guest
Posts: n/a
 
      17th Feb 2008
On Feb 17, 5:54 am, Jim <sylv1...@yahoo.com> wrote:
> Is there any way that a cell can be set up to indicate if a sheet is
> protected or unprotected?
>
> Thanks


Jim,

See ProtectContents and ProtectionMode in the Worksheets Object
Browser.

I think this should do it:

Public Function ProtectStatus() As String
Dim pStatus As Boolean

pStatus = ActiveSheet.Protect
If pStatus = True Then
ProtectStatus = "Protected"
Else
ProtectStatus = "Unprotected"
End If

End Function

Just select the cell you want to use as the indicator and then this
function from the User Defined list.

SteveM
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      17th Feb 2008
If you're looking for a visual indicator, you may want to look at the toolbars.
Lots of the formatting icons are disabled when the sheet is protected.

Jim wrote:
>
> Is there any way that a cell can be set up to indicate if a sheet is
> protected or unprotected?
>
> Thanks


--

Dave Peterson
 
Reply With Quote
 
Don Wiss
Guest
Posts: n/a
 
      17th Feb 2008
On Sun, 17 Feb 2008 05:54:23 -0800 (PST), SteveM <(E-Mail Removed)>
wrote:

>I think this should do it:
>
>Public Function ProtectStatus() As String
> Dim pStatus As Boolean
>
> pStatus = ActiveSheet.Protect
> If pStatus = True Then
> ProtectStatus = "Protected"
> Else
> ProtectStatus = "Unprotected"
> End If
>
>End Function


Why all the unnecessary code? Why not?

Public Function ProtectStatus() As String

If ActiveSheet.Protect Then
ProtectStatus = "Protected"
Else
ProtectStatus = "Unprotected"
End If

End Function

And you never need code like "pStatus = True" as pStatus is already a
boolean.

Don <www.donwiss.com> (e-mail link at home page bottom).
 
Reply With Quote
 
SteveM
Guest
Posts: n/a
 
      17th Feb 2008
On Feb 17, 10:17 am, Don Wiss <donwiss@no_spam.com> wrote:
> On Sun, 17 Feb 2008 05:54:23 -0800 (PST), SteveM <sbm...@vzavenue.net>
> wrote:
>
> >I think this should do it:

>
> >Public Function ProtectStatus() As String
> > Dim pStatus As Boolean

>
> > pStatus = ActiveSheet.Protect
> > If pStatus = True Then
> > ProtectStatus = "Protected"
> > Else
> > ProtectStatus = "Unprotected"
> > End If

>
> >End Function

>
> Why all the unnecessary code? Why not?
>
> Public Function ProtectStatus() As String
>
> If ActiveSheet.Protect Then
> ProtectStatus = "Protected"
> Else
> ProtectStatus = "Unprotected"
> End If
>
> End Function
>
> And you never need code like "pStatus = True" as pStatus is already a
> boolean.
>
> Don <www.donwiss.com> (e-mail link at home page bottom).


I suppose I could say that:

I wanted the logic to be clear to the OP. Or;
I just like the way "True" looks on a page. Or;
We haven't gotten that far yet in the Programming with Prussian
Efficiency course I'm taking. Or even;
I'm just a dope.

There may others. Take your pick.

SteveM
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to really protect cell formatting in a protected sheet =?Utf-8?B?TWFyY2VsIGRlIExhbmdl?= Microsoft Excel Discussion 2 31st Aug 2007 01:19 PM
Finding the last cell in a protected sheet =?Utf-8?B?VGlzaHlNb3VzZQ==?= Microsoft Excel Programming 4 23rd Oct 2006 03:26 PM
how to paste a fomulae cell in a protected sheet =?Utf-8?B?YW5nZWxpbmU=?= Microsoft Excel Programming 0 17th Oct 2006 05:48 AM
Can I allow cell merging in a protected sheet =?Utf-8?B?UGF0TQ==?= Microsoft Excel Worksheet Functions 1 13th Dec 2005 03:06 PM
Un-proteced Cell in a Protected Sheet =?Utf-8?B?U1U=?= Microsoft Excel Misc 1 20th Apr 2005 06:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:13 PM.