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
0
Utf
6/7/2010 7:33:18 PM
excel.programming 6508 articles. 2 followers. Follow

2 Replies
1415 Views

Similar Articles

[PageSpeed] 42

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
0
Utf
6/7/2010 7:37:10 PM
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
0
Utf
6/7/2010 8:03:14 PM
Reply:

Similar Artilces:

Integrate Paycodes, benefit codes and deduction codes
Has anyone used integration manager to update new pay rates, deduction amounts and benefit amounts for employees? At the beginning of each year, our company gives pay increases and we need to update the pay codes, deduction codes and benefit codes for 40 employees, which we get the information from a spreadsheet. I thought that maybe I could use integration manager to update the pay, benefit and deduction codes instead of going into each employee's card, which is time consuming. Thanks, Laura Integration Manager will allow you to do this. Use the Payroll Master Destination. one ...

Way to make non-selectable worksheet?
I have a spreadsheet with 4 form buttons on it that will run different macros. Is there any way to make it so the user can't click on any part of the worksheet except for the buttons? I don't want a message to pop up, I just want Excel to ignore if the user tries to click on anything except the buttons. Thanks! Botman, A couple of possibilities: You could protect the sheet (Tools - Protection - Protect Sheet. You'll want no locked cells (Format - Cells - Protection - Locked). In Excel 2002, you can specify that locked cells cannot be selected. Can't do that in XL97...

zip codes don't merge #2
I am trying to mail merge w/ Word 2000 the names and addresses in my worksheet. When I get to the part to choose the format for the mailing labels, I choose F1, F2, etc. to F6 (which is the zip code column). A few do get there, but the vast majority stop at the state, leaving off the entire zip code. I have gone to menu/format and selected text in the number tab. I have gone to format/cells and chosen special/zip code in the number tab. I've read Excel for Dummies. Please help me. TIA bb ...

concatenating two vendor codes
My company recently changed the vendor codes and now I end up with two separate sets of data for each vendor. Obviously I could just leave the vendor code field out. I don't want to do that so what I need to do is concatenate the two codes. Example Vendor Code Vendor Name 123 Joe's Supplies ABC Joe's Supplies what I need is this Vendor Code Vendor Name 123/ABC Joe's Supplies any ideas? Rather than create a new record for each vendor, add another field to the table -- call it NewVendorCode -- and put th...

Page 1, Page 2..shows up in the middle of the worksheet.
How can I get Page 1, page 2...to not show up in the middle of the worksheet on the screeen. It does not print, but it bothers me when trying to work. there are also borders that are showing up with the page 1... Please help. -- Web Traveler You are in Page Break Preview mode. Go to the View menu, and choose 'Normal'. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Tink54" <Tink54@discussions.microsoft.com> wrote in message news:A37A4591-0119-4A67-BABD-C59DD3D92381@microsoft.com... > How can I get Pag...

Turn off save work reminder
How can I stop being reminded to save my work in Publisher 2000? Thanks in advance, Josh Options, User Assistance tab, clear "Remind to save publication." -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "josh page" <josqb@cinci.rr.com> wrote in message news:46b0a69f$0$8926$4c368faf@roadrunner.com... > How can I stop being reminded to save my work in Publisher 2000? > > Thanks in advance, > Josh > ...

Excel Cell Protection / Locking Problem
Is there a way to protect formulas in a sheet (that is, locking certai cells and protecting the sheet) while still enabling users to add line in unlocked areas of the sheet? I am trying to develop a price quoting form where the user can ad extra lines (if additional line items are added) while I keep th structure of the sheet (formulas that total columns, calculate tax an so forth) intact. I have a feeling that once I protect a sheet, I am foreclosed fro adding line no matter what. Thanks -- Message posted from http://www.ExcelForum.com have you used Data Validation? This restricts wha...

Can MS EXCEL remove duplicates and separate by color coded items ?
Can MS EXCEL remove duplicates and separate by color coded items ? I am NOT technical and have just started using MS EXCEL. Can anyone PLEASE HELP me: 1. How can I automatically remove duplicates using EXCEL ? ie the same info input more than once on different lines. Can EXCEL do this ? 2, I have color coded the text in the certain lines in terms of priority. can Excel rearrange the data by color ? If yes, How do I do it ? I think I have EXCEL '97 Thanks for your help in advance. Hi 1. You can extract the unique items to a new list using menu Data > Filter > Advanced fil...

OL2002 : "header only" option works only once !!!!!
Hi, I have an IMAP account and OL2002 as client. I have check for my account ( tools, send/receive settings, define send/receive groups, <my_account>, edit, download item description only). It works only the first time i start OL2002, but it does not work anymore for subsequent automatic/manual send/receive operations. Please could someone really help me ? Thank you in advance, Patrick ...

Windows live messenger has stopped working
when I boot my PC and start Windows 7 WLM during the startup phase stops working before it has fully started. If however i start it after the boot up process is complete it works fine. I am using Window 7 64 Home Prem... and am running a new ATI 5800 series card, have 4g of ram etc..... Any ideas? I have read through the posts on this board and i do not see my problem though it is likely related to the other ones i have seen. Greetings, It might be a bit hard to isolate what's causing this without disabling other things starting at startup, as it's probably just a...

16 bit code
Hello, I have a 16 bit code to maintain. (It is too complex to copile it to 32 bit) so all we are doing is support. Now they want to add a small feature, where I need to copy long file names in the project. I know we can not do long file name copies in vc++ (1.52). So I wrote a program in VC++(6.0) which does directory copy. My questions are 1. How can I call a 32 bit exe (I guess WinExec should work)? 2. How can I make the 16 bit to wait till the 32 bit code completes? 3. Is there any other better way to do this? (other than converting to 32 bit) Thanks. I actually do this in an old 16-bi...

area codes is auto filling my own 9 digit ph# vs just area code
When I enter a phone number for a contact it autofills with my personal area code and phone number instead of just the area code. How to I change this to just autofil the area code? I am using Outlook 2007 on an ACER laptop. Make sure you have your area code entered correctly in "Dialing Properties". "Computer Dummy" wrote: > When I enter a phone number for a contact it autofills with my personal area > code and phone number instead of just the area code. How to I change this to > just autofil the area code? I am using Outlook 2007 on an ACER ...

VBA Code for Pasting Sheets
I would like a spreadhseet that pastes the contents of one sheet into another sheet. I like like to do this for 7 different sheets For example: I would like paste the contents form sheet titled "sheet1" into a sheet titled "data1". Continue to process for pasting "sheet2" into "data2" and "sheet3" into "data3" all way until "sheet7" and "data7". thanks, Curt Subject: Automated Copy Paste Subject: Copy/Paste Import/Export Data VBA Code On Apr 27, 10:49=A0am, Curt <C...@discussions.mi...

configure outlook to work with AOL
Hello...help How do I configure outlook to work with my AOL? Milt <anonymous@discussions.microsoft.com> wrote: > Hello...help > How do I configure outlook to work with my AOL? You don't. See <http://members.aol.com/adamkb/aol/mailfaq/#3rd-party>. -- Adam Bailey | Chicago, Illinois adamb@lull.org | Finger/Web for PGP & S/MIME adamkb@aol.com | http://www.lull.org/adam/ ...

options/tasks OUTLOOK 2007 not working
Example, insert picture option cloeded as if trial period over unable to use many in all office 2007 programs. Was fine for a couple days and then this. Test driving new 2007 version for my office - pretty sure I may have done something customizing. JAS Are you using HTML or RTF message format? Some of the options are only available in specific formats. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a ...

Dialoog Box Close Buttons Won't Work
Hi: I have a vc++ 6.0 program that I recently converted to an ActiveX control so that I could use it as a part of another program. The program that was converted to an ActiveX control has a number of dialog boxes that pop up to perform various functions. In the original program the dialog boxes work fine, but in the ActiveX control the dialog box won't close when the "Close" button in the upper right corner is pressed. The program gets hung up whenever this button is pressed and I need to do a "ctrl-alt-delete" and an "End Task" to close the program. Ca...

MC/VISA joint code
Isn't there any way to combine the blocks (4* & 5*) for MC/VISA credit cards? It's a pain to have them separate because my bank posts them together. It is the same company afterall. It would save me a lot of time adding separate entries together to reconcile the statement! I do not know of a way to do what you are asking, but I have found that using the # symbol as follows works better than using the * symbol: 4############### 5############### If you use the * symbol it is a wild card with no determined length. The # symbol requires that the characters after the first d...

Money 2004 - Experian Offer
I just loaded Money 2004 Deluxe and converted my 2003 files with no problem. I decided to give the free year of credit monitoring from Experian a try but after filling everything out I get an error that the provided code has expired. I neither had nor provided any code for this offer, I only used the link from Money 2004. Now Experian was more than willing to set up a $79 account if I wanted to proceed. Any solution out there? I have the same problem... I am looking for a FREE way to contact Microsoft about this problem. >-----Original Message----- >I just loaded Money 2004 ...

Analytical Accounting
Hi, One of my Client's is considering to go down AA path with approx 300,000 AA dimension codes. I would like to hear whether such data set is manageable from Query wizard etc. appreciate your thoughts. Good Morning PR, I found that the issue isn't the number of AA Trx Dim Codes it is the size of the AAG30000 and AAG40000 tables the more entries the longer it takes to product the report. I had one client that started having a cached SSRS report with AA information as a management level report and a different SSRS report with a more restrictive dataset for reporting ...

Change code with code?
Hi All..... I've got 31 Excel .xlsm files to modify the "Change Event" macro in. Is it possible to open and perform this with code, or must I do each one by hand? TIA Vaya con Dios, Chuck, CABGx3 If it is the same change in each sheet, it would probably be just as easy to go into the VBE, double click on the first sheet, make the correction, then copy that correction and double click the second sheet, delete and paste. Repeat the process 30 times. Takes less time than writing the code to do it. "CLR" <CLR@discussions.microsoft.com> wr...

Access 2003
I have a form that goes to a subform for searching. It works perfectly on my computer; however, when another user opens it and attempts to perform a search, they receive the Error Code 2455 message. When I debug, it gets stuck on "Me.book_subform.Form.Filter = strWhereSearch" and says that book_subform cannot be found. It isn't a rights issue, it isn't a mapping issue. What am I missing? check your naming. This is an issue that often confused. In this syntax: Me.book_subform.Form.Filter > = strWhereSearch book_subform is the name of the subform control on the main ...

Write a code by code
How can I write a code from procedure to some Workbook's ThisWorkbook? With procedure1 a make Workbook with a table. I need to write Auto_Close procedure to ThisWorkbook which makes some controls before I close it. Is it possible? <jenista.j@discussions.microsoft.com> wrote in message news:0be501c52fab$ba0b6830$a601280a@phx.gbl... > How can I write a code from procedure to some Workbook's > ThisWorkbook? With procedure1 a make Workbook with a table. > I need to write Auto_Close procedure to ThisWorkbook which > makes some controls before I close it. Is it possible? ...

Coding Duplicate Records
How can I code that a record is to be "K" kept or "D" deleted when compared to its next row? Example: A sorted file by Address BEFORE LastName Address Sales Date Keep/Delete 1. WASSEM 0N642 TITUS PL 67,500 6/25/2001 2. HART 0N655 E WEAVER CIR 70,000 3/19/2001 3. HART 0N655 E WEAVER CIR 40,000 3/19/2001 4. HART 0N655 WEAVER CIRCLE 33,700 6/19/1998 5. POYTH 0N662 W WEAVER CIR 294,690 6/21/2000 6. BLAND 0N670 GREEN PL ...

Can I email unique worksheets from a workbook to different users?
Hi Laura See my site for example code http://www.rondebruin.nl/sendmail.htm Maybe you like the templates -- Regards Ron de Bruin http://www.rondebruin.nl "Laura" <Laura@discussions.microsoft.com> wrote in message news:2A8220F1-590B-406F-BFC5-B692250CF29E@microsoft.com... > ...

how do i unhide all cells on an excel worksheet?
I selected my entire worksheet (by clicking the button in the upper-left corner of the worksheet frame), then I right-clicked and choose Hide. I've tried every trick I know to unhide the cells but nothing works. Does anyone have a suggestion? Thanks Select Format | Row | Unhide Regards Trevor "alliecallie" <alliecallie@discussions.microsoft.com> wrote in message news:C0D6279C-D3F1-4769-88ED-09190407C40D@microsoft.com... >I selected my entire worksheet (by clicking the button in the upper-left > corner of the worksheet frame), then I right-clicked and choose H...