ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protection Error (https://www.excelbanter.com/excel-programming/305160-re-protection-error.html)

Tom Ogilvy

Protection Error
 
Change the TakeFocusOnClick property of the Commandbutton to False

Private Sub Commandbutton1_Click()
Activesheet.Unprotect
Rows("2:16").Hidden = Not Rows(2:16).Hidden
Activesheet.Protect
End Sub

--
Regards,
Tom Ogilvy

"CDotWin" wrote in message
...
Please Help!!!

I have a macro that hides and unhides rows of cells (rows 2:16). It

is ran when a command button is clicked, however, those rows are locked. So
when the program is protected, VB cant run the macro to hide the rows and a
1004 error occurs. It says "Unable to set the hidden property of the range
class". What can I do to protect those rows, but allow the macro to run????


NOTE: I tried unprotecting the sheet before the macro runs and then

protecting it back. That doesnt seem to work. I get a 1004 error,
"Unprotect method of Worksheet class failed".




All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com