How to Fix Excel Conditional Formatting Highlighting the Wrong Rows
Question details
The user needs to resolve an issue where Excel conditional formatting rules highlight the wrong rows when using an approximate-match VLOOKUP formula.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Applying conditional formatting with a VLOOKUP formula to dynamically highlight rows based on numerical thresholds.
- Observed behavior
- Conditional formatting highlights incorrect rows because the approximate-match VLOOKUP formula fetches inaccurate results from an unsorted lookup range.
Before editing your conditional formatting rules, verify whether your VLOOKUP formula requires an exact match or an approximate threshold match, as this determines how your lookup data must be organized.
Sort the Lookup Range in Ascending Order
Approximate-match VLOOKUP relies on a binary search algorithm, which requires the first column of the lookup range to be sorted in ascending order to function correctly.
When the fourth argument of VLOOKUP is set to TRUE (or omitted), it performs an approximate match. If the lookup array is unsorted, the binary search gets confused and returns incorrect values, causing your conditional formatting to highlight the wrong rows.
Navigate to the sheet containing your lookup table and select the entire data range.
Go to the 'Data' tab on the ribbon and click on 'Sort'.
Choose the first column of your lookup table in the 'Sort by' dropdown, and set the order to 'Smallest to Largest' (A to Z).
Click 'OK' to apply the sort. Return to your main dataset and verify that the conditional formatting now highlights the correct rows.

Force an Exact Match in VLOOKUP
If your conditional formatting rule is intended to find precise values rather than approximate thresholds, you must explicitly set VLOOKUP to require an exact match.
Effortlessly Manage Conditional Formatting with WPS Spreadsheet
WPS Spreadsheet offers full compatibility with Microsoft Excel formulas, including VLOOKUP, XLOOKUP, and complex conditional formatting rules, all within a free and highly intuitive interface.
- 1. Open your data: Launch WPS Spreadsheet and open your workbook.
- 2. Select the target rows: Highlight the range of cells or entire rows where you want the conditional formatting applied.
- 3. Create a new rule: Go to the Home tab, click 'Conditional Formatting', choose 'New Rule', and select 'Use a formula to determine which cells to format'.
- 4. Apply the lookup formula: Enter your VLOOKUP formula accurately, set your preferred highlight style, and click OK to effortlessly format your data.

Frequently Asked Questions
Why does approximate-match VLOOKUP return the wrong value?
Approximate-match VLOOKUP uses a binary search algorithm. If the first column of the lookup range is not sorted in ascending order, the binary search evaluates the data incorrectly and returns an unexpected value.
Can I use XLOOKUP instead to fix the conditional formatting?
Yes. XLOOKUP does not require the data to be sorted for exact matches, and it gives you explicit control over finding the next-smaller or next-larger item if an exact match is missing. Replacing VLOOKUP with XLOOKUP is often a more robust solution.
How do I apply a conditional formatting formula to an entire row?
To highlight an entire row based on a single cell's value, you must use an absolute column reference in your formula. For example, use =$A2>50 instead of =A2>50 when setting up the rule, and apply it to the entire dataset range.




