Unhide rows based on dropdown cells

mxr1818

New Member
Joined
Feb 7, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to create a questionnaire in excel whereby you would select an answer from a dropdown list and depending on what it is e.g. “Yes”, it would unhide the row below so that another question could be asked.

I’ve searched through a few threads and I think I would have to use a macro for that (which I can’t work out how to do!) and any that I have come across tend to want to hide cells instead of unhide them.

I have listed my requirements below. If anyone could help me out it would be greatly appreciated!!!!! Thank you ??

If E13 = "Yes - optional additional benefits" then unhide row 14
If E13 = "Yes - this product is an add-on" then unhide row 15
If E13 = "Yes - this is a packaged policy" then unhide row 15
If E16 = "Yes" then unhide row 17
If E18 = "Yes" then unhide row 19
If E22 = "Yes" then unhide rows 23:25
If E25 = "Yes" then unhide row 26
If E27 = "Yes" then unhide rows 28:32
If E34 = "Yes" then unhide rows 35:36
If E38 = "Yes" then unhide row 39
If E40 = "Yes" then unhide row 41
If E42 = "Yes" then unhide row 43
If E44 = "Yes" then unhide row 45
If E46 = "Yes" then unhide row 47
If E48 = "Yes" then unhide row 49
If E54 = "Yes" then unhide row 55
If E76 = "No" then unhide row 77
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi and welcome to MrExcel

Put the following code in sheet events:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("E13,E16,E18,E22,E25,E27,E34,E38,E40,E42,E44,E46,E48,E54,E76")) Is Nothing Then
    Select Case Target.Address(0, 0)
      Case "E13"
        Rows(Target.Row + 1).Resize(2).Hidden = True
        Select Case Target.Value
          Case "Yes - optional additional benefits"
            Rows(Target.Row + 1).Hidden = False
          Case "Yes - this product is an add-on", "Yes - this is a packaged policy"
            Rows(Target.Row + 2).Hidden = False
        End Select
      Case "E16", "E18", "E25", "E38", "E40", "E42", "E44", "E46", "E48", "E54"
                  Rows(Target.Row + 1).Hidden = Target.Value <> "Yes"
      Case "E22": Rows("23:25").Hidden = Target.Value <> "Yes"
      Case "E27": Rows("28:32").Hidden = Target.Value <> "Yes"
      Case "E34": Rows("35:36").Hidden = Target.Value <> "Yes"
      Case "E76": Rows("77").Hidden = Target.Value <> "No"
    End Select
  End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0
Im glad to help you, thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,255
Messages
6,123,896
Members
449,132
Latest member
Rosie14

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