LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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".


 
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
protection error Selen Excel Worksheet Functions 2 April 30th 10 06:38 AM
Protection error Jess Excel Discussion (Misc queries) 1 November 30th 05 04:13 PM
Protection Error Frank Kabel Excel Programming 0 July 27th 04 05:33 PM
Error with protection gavin Excel Programming 4 May 10th 04 03:18 AM
Sub Error with Sheet Protection Enabled? pcsis Excel Programming 1 December 19th 03 03:59 AM


All times are GMT +1. The time now is 09:59 PM.

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

About Us

"It's about Microsoft Excel"