PDA

View Full Version : Hide or Unhide checkbox



tm1274
10-27-2005, 04:24 PM
I have this code to hide or unhide a number of rows but am getting a "run-time error 1004, unable to set hidden property of the range class" I placed the checkbox into the spreadsheet using the control toolbox and placed the code into the code editor. My checkbox is named CheckBox1 and I cannot see any other reason for this error. Anyone have any idea how to fix it?

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveSheet.Rows("3:15").EntireRow.Hidden = True
Else:
ActiveSheet.Rows("3:15").EntireRow.Hidden = False
End If


End Sub

Jacob Hilderbrand
10-27-2005, 04:49 PM
Make sure that the worksheet in unprotected and also if you have any comments that are being hidden, check their properties and make sure they are set to Move and Resize with cells.

tm1274
10-27-2005, 05:02 PM
I will do that now, thank you for your quick reply. In my sheet I have option boxes for a selection being made in column b and that result (true or false) goes into column a and tells another sheet that is doing a vlookupwhich answer to use. Would the option buttons be the cause for this?

tm1274
10-27-2005, 05:16 PM
My worksheet is definitely unprotected and I did also have comments in some of those cells. I changed those to move and size with cells but I am still having the same trouble. Can I post it here for someone to look at?

mdmackillop
10-27-2005, 05:21 PM
Hi TM,
If you zip your workbook you can post it using Manage Attachments which you will find in the Go Advanced section

tm1274
10-27-2005, 05:22 PM
Thank you, I will do that now.

tm1274
10-27-2005, 05:27 PM
Here's the workbook I am working with. Any help would be greatly appreciated.

mdmackillop
10-28-2005, 12:26 AM
The code works for me and if you change the Checkbox to 3, it should retain its position on the page. Sorry, I don't see any problems which result in the error message.
Regards
MD

tm1274
10-28-2005, 06:34 AM
Is it possible that a setting in excel could cause this problem? Or is it possible that this code is not correct for Excel 97? I cannot figure this thing out and do not know where to turn. If it works well for others there would have to be something wrong within Excel on my end?

tm1274
10-28-2005, 06:37 AM
I know this may seem a little far fetched, but would anyone within this forum lke to create a form that would do what my spreadsheet is doing and see if it make a difference? If not I will understand, I am just not hardly versed with userforms and have not grasped the full ability of the controls working with the spreadsheet to add and retrieve data from a userform.

sengerc
09-05-2006, 07:05 AM
Try removing the comments on the sheet you are having problems with. I was running into the same exact problem and your post about resizing the comments got me thinking. My sheet was erroring out, but then I remove the comments and now it worked. It may be worth a shot.

Another possible solution instead of using comments would be to use data validation, and then the input message.

Hope it works. Cheers.