Using a Checkbox to Unhide Rows

briggss1

Board Regular
Joined
Oct 23, 2006
Messages
64
I need to unhide rows on a separate sheet based on a condition where I click a checkbox, then the code would look up a range and if there is an "x" in that range, unhide the rows the "x" is in. Example:

On Sheet 1, I have three selections. I want to select one of the 3 and this will unhide resulting cells that are flagged with an X on sheet 2

1689682344003.png

Sheet 1 - B would be a check box

1689682415230.png


Sheet 2 - all information displayed. These rows will all be hidden by default. By selecting "Fajitas" on Sheet 1 (control box), I want the macro to run and lookup Sheet 2, find the Fajitas column (Col B), and unhide all of the rows with an "x" in column B. So the progression would look like this:

1689682616448.png


This is the default state of Sheet 2. When the Fajitas radio button is clicked on Sheet 1, Sheet 2 will unfilter all rows where the Fajita column conytains an "x" as follows:

1689682732733.png



After all data is done, I will have a Reset macro that will return all data rows back to hidden on Sheet 2.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
click a checkbox
When the Fajitas radio button is clicked on Sheet 1
In your request you mention a checkbox, a radiobutton but in your image you have the 'x' in a cell.
Also you don't mention if the control is a Form control or an ActiveX control.
That way it's hard to try to create code assuming what the controls are like on your sheets.

--------------------​

I show you a way to filter without code and I think it is more practical:

1. In your datasheet, select your data and create a table.
  • Select a cell within your data.
  • Select Home > Format as Table.
  • Choose a style for your table.
  • In the Create Table dialog box, set your cell range.
  • Mark if your table has headers.
  • Select OK.
1689692000085.png

2. Use slicers to filter data

  • Click anywhere in the table.
  • On the Insert tab, select Slicer.
  • Insert Slicer
  • In the Insert Slicers dialog box, select the 3 data
    1689692426231.png

  • Then select OK.

  • A slicer will be created for every field that you selected.
    1689692736482.png

  • Adjust the width and height of each button to show only the 'x'
    1689692625568.png

  • Press the 'x' on any of the slicers to filter the column, for example in Fajitas:
1689693498418.png

  • To clear a slicer's filters:
1689693041390.png

--------------
What do you think about this way of filtering without codes and everything on the same sheet.

If you still want the code, you'll need to be more specific in your request.

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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