Hiding Rows - Help!

mwillmon

New Member
Joined
May 8, 2009
Messages
2
Hello all,

I'm very new to VB programming so bear with me... I have a sheet where I have a general checkbox hiding several rows. I also have a set of checkboxes that when one of these checkboxes is selected I would like a subset of rows within the original hidden rows to be unhidden and shown only if the general checkbox is selected. I hope that makes sense. Can someone help me out with the necessary programming language? I would like to use control checkboxes and not form checkboxes as well.

thanks!

If
Checkbox 1 = true and Checkbox 2 = true, then Rows 5-10 are unhidden of the original say 50 hidden rows

If
Checkbox 1 = true and Checkbox 2 = false, then rows 5-55 are still hidden <!-- / message --><!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --><!-- END TEMPLATE: ad_showthread_firstpost_sig -->
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to the board.

One potential challenge is that you would run code every time you check or uncheck a box. Let's use 1s & 0s. you have four combos:

0,0 - hide nothing
0,1 - hide some
1,0 - hide some others
1,1 - hide all

So, if you are at 0,0 with both unchecked and you want to check both boxes (1,1), as soon as you check one, it will run the code for 1,0 or 0,1. When you check the second you will run 1,1.

If you're OK with that, you can set up a CASE macro to run when ever you check or uncheck either box.
 
Upvote 0
Try something like this:

Code:
Sub Checkbox_Cases()
ChkCombo = Sheet1.CheckBox1 & ", " & Sheet1.CheckBox2
'MsgBox ChkCombo

Select Case (ChkCombo)
    
    
    
    Case "True, True"
        Range("A5:A10").EntireRow.Hidden = False
  
    Case "True, False"
        Range("A5:A55").EntireRow.Hidden = True
    
    Case "False, True"
        Range("A25:A35").EntireRow.Hidden = True
    
    Case "False, False"
        Range("A5:A55").EntireRow.Hidden = False
    
        
    End Select
    
End Sub


The code for each checkbox could be as simple as

Code:
Private Sub CheckBox1_Click()
Checkbox_Cases
End Sub
Private Sub CheckBox2_Click()
Checkbox_Cases
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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