Hide row range when two dropdowns values are selected

Nick70

Active Member
Joined
Aug 20, 2013
Messages
299
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a sheet with two dropdowns one in cell B5 and one in cell B10.

Dropdown options are 'Yes' and 'No'.

I would like to have a macro so that if both dropdowns are showing 'Yes' then rows (20:30) are hidden (any other dropdown combination and rows(20:30) must be visible).

I need a VBA code not a filter as this is part of larger exercise (and filter would not work).

How do I do that?

Thanks,
N.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Union(Range("B5"), Range("B10"))) Is Nothing Then Exit Sub
Range("A20:A30").EntireRow.Hidden = False
    Select Case LCase(Range("B5") & Range("B10"))
        Case Is = "yesyes"
            Range("A20:A30").EntireRow.Hidden = True
        Case Else
            Range("A20:A30").EntireRow.Hidden = False
    End Select
End Sub
 
Upvote 0
Solution
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Hide rows based on two dropdown selections - OzGrid Free Excel/VBA Help Forum
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Union(Range("B5"), Range("B10"))) Is Nothing Then Exit Sub
Range("A20:A30").EntireRow.Hidden = False
    Select Case LCase(Range("B5") & Range("B10"))
        Case Is = "yesyes"
            Range("A20:A30").EntireRow.Hidden = True
        Case Else
            Range("A20:A30").EntireRow.Hidden = False
    End Select
End Sub
Thanks!
:)
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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