Need help with check boxes

Greg Determann

New Member
Joined
Jan 18, 2005
Messages
20
I am new at using VBA and only have limited knowledge of macros. I want to add several check boxes that will hide/unhide rows on another worksheet. Any ideas. Thanks in advance.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Welcome to the Board!

The following code is for ActiveX CheckBoxes from the Control Toolbox; the code goes in the sheet specific module. If you double-click a control while in Edit mode, you'll be taken to the appropriate VBA module.

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CheckBox1_Click()
    <SPAN style="color:#00007F">If</SPAN> CheckBox1.Value = <SPAN style="color:#00007F">True</SPAN> <SPAN style="color:#00007F">Then</SPAN>
        <SPAN style="color:#007F00">'   Hide a row when checked</SPAN>
        Sheets("Sheet2").Range("A1").EntireRow.Hidden = <SPAN style="color:#00007F">True</SPAN>
    <SPAN style="color:#00007F">Else</SPAN>
        <SPAN style="color:#007F00">'   Unhide when unchecked</SPAN>
        Sheets("Sheet2").Range("A1").EntireRow.Hidden = <SPAN style="color:#00007F">False</SPAN>
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 
Upvote 0
pennysaver said:
Welcome to the Board!

The following code is for ActiveX CheckBoxes from the Control Toolbox; the code goes in the sheet specific module. If you double-click a control while in Edit mode, you'll be taken to the appropriate VBA module.

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CheckBox1_Click()
<SPAN style="color:#00007F">If</SPAN> CheckBox1.Value = <SPAN style="color:#00007F">True</SPAN> <SPAN style="color:#00007F">Then</SPAN>
<SPAN style="color:#007F00">' Hide a row when checked</SPAN>
Sheets("Sheet2").Range("A1").EntireRow.Hidden = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">Else</SPAN>
<SPAN style="color:#007F00">' Unhide when unchecked</SPAN>
Sheets("Sheet2").Range("A1").EntireRow.Hidden = <SPAN style="color:#00007F">False</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty

Hi, I'm a little new to VBA, and was wondering if you could tell me what ActiveX control boxes are. I know that there are 2 basic types, your form and the checkboxes from the control toolbox. Basically, i'm trying to create a script so that when you click on the ALL checkbox, it automatically checks off checkboxes 1 through 6. Similarly if you click Reset, it deselects them all...

I've tried using your script, but when i try to run it, i get a runtime error. (424 saying that an object is required)

This is what i have so far:

Private Sub CheckBox1_Click()
If CheckBox6.Value = True Then
' Hide a row when checked
Sheets("Sheet2").Range("A1").EntireRow.Hidden = True
Else
' Unhide when unchecked
Sheets("Sheet2").Range("A1").EntireRow.Hidden = False
End If
End Sub


any thoughts? thanks![/list]
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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