Excel Formula to Match Two Conditions and Compare Values
Question details
The user needs a formula that matches two criteria and returns a value only when one cell is greater than or equal to another.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Compare B26 with B27, then match B24 and B25 against columns A and B and return the corresponding value from column F.
- Observed behavior
- The desired result is zero when B26 is less than B27, the matching value from column F otherwise, or a blank when no match is found.
Check that B24 and B25 contain the lookup criteria and that B26 and B27 contain comparable values. Confirm that rows 33 through 38 contain the criteria in columns A and B and the return values in column F.
Use IF and XLOOKUP to match both criteria
Use this formula in Excel for Microsoft 365 to compare the two cells and return the first matching value.
Click the cell where you want the result to appear.
Type =IF(B26<B27,0,XLOOKUP(1,(B24=$A$33:$A$38)*(B25=$B$33:$B$38),$F$33:$F$38,"")) in the formula bar and press Enter.
Change the values in B24 through B27 to test the formula. It returns 0 when B26 is less than B27; otherwise, it returns the first matching value from column F or a blank if no row matches.

Use nested IF formulas without XLOOKUP
Use this option when XLOOKUP is unavailable and the lookup range contains only a few rows.
Match Two Conditions in WPS Spreadsheets
Use a nested IF formula in WPS Spreadsheets to compare two cells and return the value from the first row that matches both criteria.
- 1. Open your spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
- 2. Check the source cells: Enter or verify the criteria in B24 and B25, the comparison values in B26 and B27, and the lookup data in A33:B38 and F33:F38.
- 3. Enter the formula: Select an empty result cell and enter =IF(B26<B27,0,IF(AND(B24=A33,B25=B33),F33,IF(AND(B24=A34,B25=B34),F34,IF(AND(B24=A35,B25=B35),F35,IF(AND(B24=A36,B25=B36),F36,IF(AND(B24=A37,B25=B37),F37,IF(AND(B24=A38,B25=B38),F38,""))))))) in the formula bar, then press Enter.
- 4. Verify the result: Check the result cell: it should show 0 if B26 is less than B27, the first matching value from column F otherwise, or a blank if no row matches.

Frequently Asked Questions
What happens when B26 equals B27?
The formula performs the lookup because the test B26<B27 is false when the values are equal.
What does the formula return if neither row matches both criteria?
It returns a blank string. In the XLOOKUP formula, the final "" argument specifies the result when no match is found.
What if more than one row matches both criteria?
Both formulas return the value from the first matching row in the specified range.
Can I use the formula without XLOOKUP?
Yes. Enter the nested IF and AND formula in the result cell. It checks each row individually, so you must add conditions for any rows beyond row 38.




