PC Review


Reply
Thread Tools Rate Thread

Code not working in a PROTECTED Worksheet

 
 
Ayo
Guest
Posts: n/a
 
      7th Jun 2010
I have the code below in a worksheet on a file in SharePoint. The worksheet
is Protected so only unprotected Cells are selectable. The problem I am
having is that when the sheet is protected I get an error on:
Me.Rows("5:169").EntireRow.Hidden = False
and I know it is because on the protection because when I remove the
protection from the sheet, the macro works fine. Is there a way around this
problem?

Private Sub cmdCPA_Click()
Application.ScreenUpdating = False
Me.Rows("5:169").EntireRow.Hidden = False
ActiveWindow.ScrollRow = 4
ActiveSheet.Range("20:169").EntireRow.Hidden = True
Application.ScreenUpdating = True
End Sub
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      7th Jun 2010
I think you just answered your own question. Unprotect the sheet, run the
code you have, re-protect the sheet.


Sheets("Sheet1").Select
ActiveSheet.Unprotect

'your code in here

Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True '
or whatever kind of protection you need...turn on the macro recorder and go
through the steps...that's the easiest way...



--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Ayo" wrote:

> I have the code below in a worksheet on a file in SharePoint. The worksheet
> is Protected so only unprotected Cells are selectable. The problem I am
> having is that when the sheet is protected I get an error on:
> Me.Rows("5:169").EntireRow.Hidden = False
> and I know it is because on the protection because when I remove the
> protection from the sheet, the macro works fine. Is there a way around this
> problem?
>
> Private Sub cmdCPA_Click()
> Application.ScreenUpdating = False
> Me.Rows("5:169").EntireRow.Hidden = False
> ActiveWindow.ScrollRow = 4
> ActiveSheet.Range("20:169").EntireRow.Hidden = True
> Application.ScreenUpdating = True
> End Sub

 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      7th Jun 2010
Thanks.

"ryguy7272" wrote:

> I think you just answered your own question. Unprotect the sheet, run the
> code you have, re-protect the sheet.
>
>
> Sheets("Sheet1").Select
> ActiveSheet.Unprotect
>
> 'your code in here
>
> Sheets("Sheet1").Select
> ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True '
> or whatever kind of protection you need...turn on the macro recorder and go
> through the steps...that's the easiest way...
>
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "Ayo" wrote:
>
> > I have the code below in a worksheet on a file in SharePoint. The worksheet
> > is Protected so only unprotected Cells are selectable. The problem I am
> > having is that when the sheet is protected I get an error on:
> > Me.Rows("5:169").EntireRow.Hidden = False
> > and I know it is because on the protection because when I remove the
> > protection from the sheet, the macro works fine. Is there a way around this
> > problem?
> >
> > Private Sub cmdCPA_Click()
> > Application.ScreenUpdating = False
> > Me.Rows("5:169").EntireRow.Hidden = False
> > ActiveWindow.ScrollRow = 4
> > ActiveSheet.Range("20:169").EntireRow.Hidden = True
> > Application.ScreenUpdating = True
> > End Sub

 
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
Hyperlinks in cells in a protected worksheet not working NealB Microsoft Excel Misc 5 17th Feb 2011 11:15 PM
Enable code in a password protected worksheet Barattolo_67 Microsoft Excel Misc 3 14th Feb 2010 12:51 PM
How to get worksheet change code to work on protected worksheet? StargateFan Microsoft Excel Programming 4 16th Feb 2009 02:40 PM
Protected Worksheet - tabs stop working in certain areas =?Utf-8?B?YnVja2V0b3dhdGVy?= Microsoft Excel Misc 0 26th Jan 2006 05:27 AM
check if worksheet is protected using code neowok Microsoft Excel Programming 2 14th Jul 2004 02:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 AM.