Hide/Show rows in a different sheet based on Yes/No responses

behandy10

New Member
Joined
Dec 21, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I am trying to build a macro that will hide or show a group of rows in the Options sheet (shown below) based on the Yes/No responses from the Questions sheet. Essentially, someone will fill out the Questions sheet to narrow down what they actually need to see and then further define their needs from what shows on the Options sheet. If Item 1 is set to Yes, then all rows with Item1 in Options Column A should show. If Item 1 is set to No, those rows will be hidden. I've tried a dozen or so different coding formats and nothing has worked. Any and all guidance appreciated!!

Questions sheet:
1640115328988.png


Options sheet:
1640115362593.png
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You could also use this behind a worksheet_change event

VBA Code:
Sub jec()
 Dim ar, ar2, sq, it, y As Variant
 
 ar = Sheets(1).Range("A2:B7")
 Set ar2 = Sheets(2).Cells(1, 1).CurrentRegion
 Set sq = Sheets(2).Cells(999, 1)
 
 ar2.EntireRow.Hidden = False
 
 With Application
   For Each it In ar2.Columns(1).Cells
     y = .Match(it, .Index(ar, 0, 1), 0)
     If IsNumeric(y) Then If .Index(ar, y, 2) <> "Yes" Then Set sq = Union(sq, it)
   Next
 End With
 
 sq.EntireRow.Hidden = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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