VBA & Macro Problems

Fix Excel VBA AutoFilter Criteria for Formatted Numbers

Huda QurayshiHuda Qurayshi Nov 14, 2026 870 views

Question details

The user needs to filter numeric values reliably in Excel VBA when their displayed number format differs from the criterion.

Fix Excel VBA AutoFilter Criteria for Formatted Numbers
Product
Microsoft Excel VBA AutoFilter
Device & OS
not provided
Scenario
A VBA macro filters a column containing a number such as 1000 that is displayed as 1,000 or 1000.00.
Observed behavior
The filter may return no matching rows for 1000 even though a matching formatted value is visible.
Before you start

Check whether the target cells contain numbers or text, and note the exact displayed format. Identify the filter range and the target column's position within that range.

Solution 1Recommended

Use Equal Lower and Upper Numeric Filter Criteria

Use a numeric range when an exact criterion does not match the formatted display.

Setting the lower and upper bounds to the same value targets that numeric value without relying on a single displayed-text criterion.

1
Open the VBA editor

In Excel, open Developer > Visual Basic, then open the module containing your filter macro.

2
Replace the filter criterion

Use a range criterion, for example: Dim FilterValue As Double: FilterValue = 1000 ActiveSheet.Range("A1:D100").AutoFilter Field:=1, Criteria1:=">=" & FilterValue, Operator:=xlAnd, Criteria2:="<=" & FilterValue

3
Adjust and test the range

Replace A1:D100 with your data range, including its header row, and set Field to the target column's position within that range. Run the macro from Developer > Macros and check the visible rows.

Use Equal Lower and Upper Numeric Filter Criteria
Check the underlying values: Equal bounds match the underlying numeric value, not every value rounded to the same display. Text values may need conversion before numeric filtering.
Free Microsoft Office alternative

Work with Formatted Numbers in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface for working with spreadsheet data. Open compatible Excel files and migrate everyday spreadsheet work with ease; it does not fix Excel's VBA AutoFilter behavior.

Filter and review formatted numbers in WPS SpreadsheetsOpen and edit Microsoft Excel XLS and XLSX filesUse a familiar spreadsheet interface for everyday tasksSwitch to a free, lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Why does filtering for 1000 return no rows when I can see 1,000?

Excel may interpret the criterion differently from the displayed value. Try the displayed value in the filter dropdown or use equal numeric lower and upper bounds in VBA.

What does Field mean in the AutoFilter VBA command?

Field is the target column's position within the specified filter range. For Range("A1:D100"), Field:=1 filters column A and Field:=2 filters column B.

Will equal numeric bounds match values displayed as 1,000 after rounding?

Not necessarily. Criteria of >=1000 and <=1000 target the underlying value 1000, so a different value rounded to look like 1,000 may not match.

How can I filter numbers stored as text?

Create a helper column with =IFERROR(VALUE(A2),""), fill it down, and check that the results are numeric. Apply the filter to the helper column.