Hide/unhide rows with buttons

tracktor

Board Regular
Joined
Sep 13, 2009
Messages
62
I am using several toggle buttons to hide/show rows of data related to the specific toggle buttons. I also want to hide and show the toggle buttons as well. When I try to do that the data underneath the toggle buttons is hidden but the toggle buttons don't hide with the cells.

A solution for the problem that I am having would be to have the ability to click on a cell as if it were a toggle button and hide/show rows of data when clicked.

OR

If there is a way to hide/show buttons as well would work too.

Your help is greatly appreciated.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi !

You can do that by recording a macro and making a textbox and assigning the macro to textbox and add the text you like in text box like Show/Hide.

Hope this helps.
 
Upvote 0
No. That does not work. If I add any control button or text box when I try to hide that row the control stacks up over the unhidden rows. That is what I am trying to avoid.

Basically I want to "toggle" a cell to hide or unhide specific rows. And if I want to hide or unhide the cell with another toggle cell then it will hide as well.
 
Last edited:
Upvote 0
No. That does not work. If I add any control button or text box when I try to hide that row the control stacks up over the unhidden rows. That is what I am trying to avoid.

Basically I want to "toggle" a cell to hide or unhide specific rows. And if I want to hide or unhide the cell with another toggle cell then it will hide as well.

Hi !

You can try this:

1. Start recording the macro.
2. Select the rows (multiple rows by holding Ctrl + the specific rows' numbers).
3. The particular rows will be highlighted.
4. Release the Ctrl button.
5. Go to Home (if using Excel 2007), click format, Unhide and Hide, then click hide rows.
6. Since whatever you are doing, is being recorded behind the scenes in excel memory. Then stop recording the macro.
7. Create a textbox wherever you like. Add text if you want.
8. Right-click the textbox and then click Assign Macro and from the list choose the one you just recorded.

Now you are textbox is ready. Play with it if you like.

Hope this helps.
 
Upvote 0
Actually you can make two textboxes. One for Hide and one for Unhide. Do the same process for unhide (with macro).

Hope this helps.:cool:
 
Upvote 0
I cant use text boxes or any other control as the controls themselves can't be hidden. That is why I want to be able to select a cell to do the hiding and showing of rows.
 
Last edited:
Upvote 0
Select ToggleButton > Right Click > Format Control > Properties > Move and size with cells > Ok
Is it?

Or you mean: ToggleButton1.Visible = Not ToggleButton1.Visible ' True/False
 
Last edited:
Upvote 0
I have figured out how to write the code to hide and show rows but I have to use 2 different cells (A24,A25). I just want to use one cell to hide and/or show the rows.

Here is the code i wrote

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Cells.Count > 1 Then Exit Sub

        If Not Intersect(Target, Range("A25")) Is Nothing Then

                If Target = "" Then
                
                    Rows("25:30").Select
                    Selection.EntireRow.Hidden = True

                    Rows("24").Select
                    Selection.EntireRow.Hidden = False

                End If

        End If

        If Not Intersect(Target, Range("A24")) Is Nothing Then

                If Target = "" Then
                
                    Rows("25:30").Select
                    Selection.EntireRow.Hidden = False

                    Rows("24").Select
                    Selection.EntireRow.Hidden = True

                End If

        End If
End Sub
 
Upvote 0
The toggle buttons move and size with cells but they don't hide with cells. Once again... I can't use controls when hiding rows.
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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