Hide multiple non contiguous Rows based on Dropdown List

jondu

Board Regular
Joined
Feb 6, 2019
Messages
71
Hi,
I'm a newbie in Excel. Could you help me to code for hidding rows that are non consecutives ?

My cell A1 is a dropdown menu, with the choice between Value1 and Value2.

I found this (adapted to be simple), wich is working :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    If Not Intersect(Target, Range("$A$1")) Is Nothing Then
        With Range("$A$1")
            Range("10:14").EntireRow.Hidden = .Value = "Value1"
            Range("15:20").EntireRow.Hidden = .Value = "Value2"
            Range("21:25").EntireRow.Hidden = .Value = "Value1"
            Range("26:30").EntireRow.Hidden = .Value = "Value2"
            Range("31:35").EntireRow.Hidden = .Value = "Value1"
            Range("36:40").EntireRow.Hidden = .Value = "Value2"
            Range("41:45").EntireRow.Hidden = .Value = "Value1"
            Range("46:50").EntireRow.Hidden = .Value = "Value2"
        End With
    End If
End Sub

But the problem : I want to add another dropdown choice, in another cell, let's say in A2.
How can I make it to enrich my code ??

I have been busy for so long ...Thanks !
 
Glad to help & thanks for the feedback
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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