VBA & Macro Problems

Use Excel VBA Advanced Filter With Multiple Selected Criteria

Ayan MasoodAyan Masood Nov 22, 2026 871 views

Question details

Apply an Excel VBA Advanced Filter using multiple values selected in list boxes.

Use Excel VBA Advanced Filter With Multiple Selected Criteria
Product
Microsoft Excel
Device & OS
not provided
Scenario
A VBA routine writes selections from multiselect list boxes to an Advanced Filter criteria range.
Observed behavior
Values placed on one criteria row are treated as conditions that must all be met, rather than as alternative matches. A proposed criteria range also overlaps another criteria area.
Before you start

Check the source table's column headers and identify an unused area on the same worksheet for the criteria range. If existing criteria occupy BH1:BJ2, choose a range that does not include any of those cells.

Solution 1Recommended

Place Alternative Criteria on Separate Rows

Use separate criteria rows for OR conditions and keep conditions that must apply together on the same row.

Advanced Filter combines criteria across a row with AND and combines separate criteria rows with OR. If selections from two list boxes must both apply, create a row for every required combination of their selected values.

1
Create a separate criteria area

On the source worksheet, reserve an unused range such as BN1:BO5. Enter column headers in BN1 and BO1 that exactly match the source headers, such as Region and Status.

2
Write each combination on its own row

For example, to match either East or West with either Open or Pending, enter East/Open in BN2:BO2, East/Pending in BN3:BO3, West/Open in BN4:BO4, and West/Pending in BN5:BO5. Update the list-box routine to generate these combinations from the selected values.

3
Pass the full range to Advanced Filter

In the VBA editor, use the header and all populated criteria rows as CriteriaRange. For example, with source data in A1:F100 on the Data sheet, use: Worksheets("Data").Range("A1:F100").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Worksheets("Data").Range("BN1:BO5"), Unique:=False. Adjust both ranges to match the workbook.

4
Resize and test the criteria

Run the macro with different list-box selections and update the CriteriaRange to include the header plus every generated row. Clear old entries within the reserved criteria area before writing a shorter set of selections.

Place Alternative Criteria on Separate Rows
Avoid overlapping criteria: BJ1:BL6 overlaps BH1:BJ2 in column BJ. Use a separate area, and make sure it has enough empty rows for all generated combinations.
Free Microsoft Office alternative

Work With Filtered Spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility, making it easy to move everyday spreadsheet work. It does not fix Excel's VBA Advanced Filter behavior.

Filter and review spreadsheet data in WPS SpreadsheetsOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar interface for a smoother transition from ExcelWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

How do I filter for any of several values in one column?

Enter the exact source column header in the criteria area, then put each alternative value on a separate row beneath it. Include the header and all value rows in the VBA CriteriaRange.

How do I combine selections from two list boxes?

Put the two matching column headers side by side in the criteria area. Create a separate row for each selected-value combination that should match; conditions on each row are joined with AND.

Why should I avoid using BJ1:BL6 for the new criteria?

If another criteria area occupies BH1:BJ2, the ranges overlap in column BJ. Choose an unused area, such as BN1:BO5 if those cells are available, and update the VBA CriteriaRange.

What should I check if Excel reports an invalid criteria range?

Make sure CriteriaRange refers to a valid worksheet range containing the criteria headers and at least one criteria row. Check that the headers exactly match the source columns and that the range does not overlap another criteria area.