Replace Long IF Formulas with an Excel Two-Way Lookup Table
Question details
Replace a lengthy IF, AND, and OR formula with a two-way lookup that returns text based on values in columns B and E.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet needs to return a text result for each combination of values in columns B and E.
- Observed behavior
- A lookup table should provide the appropriate text for each combination without requiring a long nested formula.
List the possible values from columns B and E and decide what text each combination should return. Make sure the lookup values match the source data exactly.
Use INDEX and MATCH with a Two-Way Lookup Table
Use this method to maintain the possible results in a table rather than a long formula.
Enter the possible column E values in J3:J9 and the possible column B values across K2:N2.
In K3:N9, enter the text to return for each intersection of an E value and a B value.
Select G2 and enter =INDEX($K$3:$N$9,MATCH(E2,$J$3:$J$9,0),MATCH(B2,$K$2:$N$2,0)).
Drag the fill handle from G2 down column G to apply the lookup to the remaining rows.

Build the Same Two-Way Lookup in WPS Spreadsheet
Use INDEX and MATCH in WPS Spreadsheet to return text from a table based on values in columns B and E.
- 1. Open your worksheet: Open the workbook in WPS Spreadsheet and select the sheet containing columns B and E.
- 2. Create the lookup table: Enter E values in J3:J9, B values in K2:N2, and the corresponding text results in K3:N9.
- 3. Enter the lookup formula: Select G2 and enter =INDEX($K$3:$N$9,MATCH(E2,$J$3:$J$9,0),MATCH(B2,$K$2:$N$2,0)).
- 4. Apply it to other rows: Drag the fill handle from G2 down to calculate results for the other rows.

Frequently Asked Questions
What does each MATCH function look up?
MATCH(E2,$J$3:$J$9,0) finds the row for the E value, while MATCH(B2,$K$2:$N$2,0) finds the column for the B value. INDEX returns the result at their intersection.
Why does the formula return #N/A?
One or both source values may be missing from the lookup headers. Check that E2 matches an entry in J3:J9 and B2 matches an entry in K2:N2, including spaces and data types.
How can I display a message instead of #N/A?
Wrap the formula in IFERROR, for example: =IFERROR(INDEX($K$3:$N$9,MATCH(E2,$J$3:$J$9,0),MATCH(B2,$K$2:$N$2,0)),"Not found"). This also replaces other formula errors with the message.
Can I use a larger lookup table?
Yes. Expand the INDEX range and the corresponding row and column MATCH ranges together. The INDEX range must have the same number of rows as the E-value range and the same number of columns as the B-value range.




