Hide and unhide rows and checkboxes

Holland

New Member
Joined
Mar 21, 2011
Messages
3
I am making a workbook for work. They want certain rows and checkboxes hidden untill a checkbox is activated. I got the code to hide them but if I save the file with them hidden and reopen the file and unhide them, all the checkboxes are in the wrong place. Is there any way to keep them to a cell or a different thing i should be using.

Code:
Private Sub CheckBox2_Click()
Dim i% 'for loops in If statments
Dim o%, cbf%, cbl%
o = 35 'object number
cbf = 36 'first checkbox number
cbl = 59 'last checkbox number
'stops page refresh
Application.ScreenUpdating = False
If CheckBox2.Value = True Then
    Shapes("Object " & o).Visible = True
    Rows("31:52").EntireRow.Hidden = False
    For i = cbf To cbl
    CheckBoxes("Check Box " & i).Visible = True
Next
Else
    Shapes("Object " & o).Visible = False
    Rows("31:52").EntireRow.Hidden = True
    For i = cbf To cbl
    CheckBoxes("Check Box " & i).Visible = False
Next
End If
'Refreshes Page
Application.ScreenUpdating = True
End Sub

I'm using check box (form Control) for the checkboxes in the cells

The checkboxes for the code are ActiveX Control

Excel 2010

Thanks

Edit
I also need them to follow the cells =S
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top