How to Hide Buttons When Range or Row is Also Hidden

LaneFowler

New Member
Joined
Jul 14, 2010
Messages
30
I have a Workshet that contains a Checkbox from the Control Toolbar. When the Checkbox is checked, non-adjacent rows are un-hidden, and when the checkbox is unchecked, the non-adjacent rows are hidden.

The rows in question contain buttons that activate other macros. The Problem I have is that when the Checkbox is unchecked and the rows in question are hidden, the buttons continue to show. I need a macros to hide the buttons when the rows that sit under the buttons are also hdden, i.e., a button on top of row 3 should also be hidden when row 3 is hidden.

The buttons are clipart from the AutoShapes Toolbar.

My Macros is below. Each of the rows that are hidden/unhidden by the checkbox contain 2 additional buttons that should be hidden when the rows are hidden.

Private Sub CheckBox1_Click()
If Sheet1.CheckBox1 Then
Rows("3").Hidden = False
Rows("18").Hidden = False
Rows("169").Hidden = False
Rows("208").Hidden = False
Rows("216").Hidden = False
Rows("255").Hidden = False
Else
Rows("3").Hidden = True
Rows("18").Hidden = True
Rows("169").Hidden = True
Rows("208").Hidden = True
Rows("216").Hidden = True
Rows("255").Hidden = True
End If
End Sub

Help is appreciated!
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,796
Office Version
  1. 2019
Platform
  1. Windows
Maybe like this:

Code:
Private Sub CheckBox1_Click()

If Sheet1.CheckBox1 Then

    Rows("3").Hidden = False
    Rows("18").Hidden = False
    Rows("169").Hidden = False
    Rows("208").Hidden = False
    Rows("216").Hidden = False
    Rows("255").Hidden = False
    [COLOR="Blue"]Sheet1.CommandButton1.Visible = True[/COLOR]

Else

    Rows("3").Hidden = True
    Rows("18").Hidden = True
    Rows("169").Hidden = True
    Rows("208").Hidden = True
    Rows("216").Hidden = True
    Rows("255").Hidden = True
    [COLOR="Blue"]Sheet1.CommandButton1.Visible = False[/COLOR]

End If

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,402
Messages
5,601,475
Members
414,452
Latest member
Dannysamworth

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