Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Code not working in a PROTECTED Worksheet

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Code not working in a PROTECTED Worksheet

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Code not working in a PROTECTED Worksheet

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get worksheet change code to work on protected worksheet? StargateFan Excel Programming 4 February 16th 09 02:40 PM
Hyperlinks in cells in a protected worksheet not working NealB Excel Discussion (Misc queries) 3 September 11th 08 10:20 PM
Range Validation property not working w/ Protected worksheet KES[_2_] Excel Programming 0 October 3rd 07 05:54 AM
Protected Worksheet - tabs stop working in certain areas bucketowater Excel Discussion (Misc queries) 0 January 26th 06 05:27 AM
check if worksheet is protected using code neowok[_68_] Excel Programming 2 July 14th 04 02:30 PM


All times are GMT +1. The time now is 04:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"