Macros on a protected sheet


Posted by Chris Jones on August 15, 2001 8:17 AM

Hey there,

Any help here would be greatly appreciated


I created a simple macro that is as follows:

Rows("17:29").Select
Selection.EntireRow.Hidden = False
Rows("22:28").Select
Selection.EntireRow.Hidden = True

It works, however, it is on a sheet that I want protected. When I protect the sheet the macro doesn't work anymore. What can I do to get it to work when the sheet is protected.


Posted by neo on August 15, 2001 8:24 AM

try this :

sheet1.unprotect("yourpassword")
Rows("17:29").Select
Selection.EntireRow.Hidden = False
Rows("22:28").Select
Selection.EntireRow.Hidden = True
sheet1.protect("yourpassword")

those two lines of code will turn on and off protection before and after the macro. also if you add 'application.screenupdating = false' before all the other code, you won't see your macro run, and it'll run a little faster...

neo



Posted by Chris Jones on August 15, 2001 8:37 AM

Hello neo,

Thanks for the help but it says to me

"Unable to set the Hidden property of the Range Class" Error 1004

Then when I go to the code this line is highlighted

Selection.EntireRow.Hidden = False