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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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
 

Greg Determann

New Member
Joined
Jan 18, 2005
Messages
20
Thanks a million - this board is impressive. Already added to my favorites - I'll be posting questions every day!
 

vincenthuang

New Member
Joined
Mar 28, 2005
Messages
23
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]
 

Forum statistics

Threads
1,147,621
Messages
5,742,180
Members
423,709
Latest member
AMacL

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
Top