Checkbox hides a row

grassman20

New Member
Joined
Oct 12, 2009
Messages
2
I have a spreadsheet with 188 rows. More specifically, 94 rows of 2. I want a check box in row1 to hide/unhide row2. By default, the box is unchecked and the row is hidden. When the box is checked, the row appears. Unchecking it makes it disappear again. I want to repeat this 94 times, starting with row3 and ending with row90.

I figger this will require some VB skills, of which I have none. I can do most of what I need with algebraic formulas in cells, but I don't think I can avoid VB on this one.

I'm not a coder or a programmer and have only a basic understanding of how code is generally structured. So please make it simple because I'm basically a moron.

Thanks.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You could try this;

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Rows("7:7").Select
Selection.EntireRow.Hidden = True
Else
Selection.EntireRow.Hidden = False
End If
End Sub

this hides/unhides row 7, amend to suit. one of the code gurus could make it a lot sleeker for all of the rows you need.

Cheers
Colin
 
Upvote 0
I appreciate the help, although I have no idea how to implement it. I assume there's somewhere I can go in my worksheet to go paste the code. And do I just repeat the code 94 times? Is there a more efficient way to handle 94 checkboxen?
 
Upvote 0
That is just a recorded macro to hide row 7 (I just picked any row to record the macro). The code is pasted into the desired checkbox (Though change the 7 to suit). On how to implement it to cover 94 rows and hide/unhide as per selection, then I'm afraid I resort to my last comment and hope one of the code guru's step in.

Sorry
Colin
 
Upvote 0
It appears you want to keep the Odd rows visible, with the option to show the even rows when needed. I would just use a DoubleClick
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Select Case Target.Row Mod 2
Case 1
Cells(Target.Row + 1, 1).EntireRow.Hidden = False
Case 0
Cells(Target.Row, 1).EntireRow.Hidden = True
End Select
End Sub
This code will unhide the row below when clicked on an Odd row and Hide the row clicked on if it is even,. This allows you to toggle the Even row between hidden and visible!!
HTH
lenze
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,947
Members
449,480
Latest member
yesitisasport

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