Survey - Hide rows if N is selected Unhide Rows if Yes is selected

thelad

Board Regular
Joined
Jan 28, 2011
Messages
245
Hi,

I am completing a survey on excel in which I ask a number of questions. I would like to unhide and leave rows hidden based on User selecting Yes or No

If No is selected from dropdown list (Yes or No Can be Selected) in row 13 it leaves row 14 to 24 hidden, but if Yes is Selected it will unhide the rows 14 to 24. To note there will be numerous columns that can be yes or no.

For Example D13 to AB13 might have yes or no to be selected. One occurrence of Yes will cause the rows to unhide.

YES/NO selection will start from D13 but can go to H13 or itcould go to AB13...so the test to see if Yes /No is selected needs to be dynamic.

Any help Appreciated.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Right-click on the sheet tab name at the bottom of your sheet, select "View Code", and paste this code in the resulting VB Editor window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    
'   Enter range to consider
    Set rng = Range("D13:AB13")
    
'   Run macro if a cell in the above range is changed
    If Not Intersect(Target, rng) Is Nothing Then
'       If any cells in rng is "Yes", unhide rows
        If Application.WorksheetFunction.CountIf(rng, "Yes") > 0 Then
            Rows("14:24").EntireRow.Hidden = False
        Else
            Rows("14:24").EntireRow.Hidden = True
        End If
    End If
    
End Sub
Then, anytime a value is updated in the range D13:AB13, if there are any "Yes" values in that range, rows 14:24 will be visible, else they will be hidden.
 
Upvote 0
Hi Joe,

Thanks for that. Can the D13 to AB13 b dynamic In any way?

AB13 might not be last column, t could go out Further for user to select yes/No
 
Upvote 0
Why not just make it the last possible column you might ever use (if it could be any, then try "XFD13")?
Would there be any danger in doing that?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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