Filter Results Based on Multiple Drop Down Selections

alyssaccasey

New Member
Joined
Aug 23, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi- I'm looking for a way to show results based on multiple drop down selections and ALSO include all results if one (or more) of the fields is left blank. I'm fine with using a macro is that's necessary. In the below instance, I selected a country, city, currency, and region, and wanted all the company names that match those criteria. I also want it to be able to return all values even if one (or more) of the search criteria are blank (i.e. if I only fill in USA for the country, there should be three company names that are returned). Thanks in advance for your help!!!

1629731191041.png
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Welcome to the MrExcel forum!

Try:

Book4
ABCDEFG
1CountryCityCurrencyRegionCompany Name2
2Drop-Down Filters:USAMiamiUSDNorth AmericaCoca Cola
3Amazon
4
5CountryCityCurrencyRegionCompany Name2
6USAMiamiUSDNorth AmericaCoca Cola
7USAMiamiUSDNorth AmericaAmazon
8USANew YorkUSDNorth AmericaToyota
9IrelandDublinEuroEuropeChase
10IrelandDublinEuroEuropeDell
11AustraliaMelbourneUADAPACApple
12PolandWarsawPLNEuropeLowe's
Sheet1
Cell Formulas
RangeFormula
G2:G3G2=FILTER(E6:E12,((A6:A12=B2)+(B2=""))*((B6:B12=C2)+(C2=""))*((C6:C12=D2)+(D2=""))*((D6:D12=E2)+(E2="")))
Dynamic array formulas.
 
Upvote 0
Solution
VBA Code:
Sub Advanced_Filtering()
'https://www.goskills.com/Excel/Resources/Excel-VBA-advanced-filter
    CriteriaLastRow = 3

    For i = 2 To CriteriaLastRow
        RowsCount = Application.WorksheetFunction.CountA(Range("B" & i & ":F" & i))
        If RowsCount = 0 Then CriteriaRowsSet = i - 1 Else CriteriaRowsSet = CriteriaLastRow
    Next i

    Range("A4:E" & Rows.Count).AdvancedFilter _
            Action:=xlFilterInPlace, _
            CriteriaRange:=Range("B1:F" & CriteriaRowsSet)
End Sub
 
Upvote 0
Welcome to the MrExcel forum!

Try:

Book4
ABCDEFG
1CountryCityCurrencyRegionCompany Name2
2Drop-Down Filters:USAMiamiUSDNorth AmericaCoca Cola
3Amazon
4
5CountryCityCurrencyRegionCompany Name2
6USAMiamiUSDNorth AmericaCoca Cola
7USAMiamiUSDNorth AmericaAmazon
8USANew YorkUSDNorth AmericaToyota
9IrelandDublinEuroEuropeChase
10IrelandDublinEuroEuropeDell
11AustraliaMelbourneUADAPACApple
12PolandWarsawPLNEuropeLowe's
Sheet1
Cell Formulas
RangeFormula
G2:G3G2=FILTER(E6:E12,((A6:A12=B2)+(B2=""))*((B6:B12=C2)+(C2=""))*((C6:C12=D2)+(D2=""))*((D6:D12=E2)+(E2="")))
Dynamic array formulas.
Thank you!!!!!
 
Upvote 0
And a bit more obscure, but here's a shorter way to write that formula:

Excel Formula:
=FILTER(E6:E12,MMULT((A6:D12=B2:E2)+(B2:E2=""),{1;1;1;1})=4)
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

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