Function Problems

Replace Long IF Formulas with an Excel Two-Way Lookup Table

Natalie TaylorNatalie Taylor Dec 2, 2026 869 views

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.

Replace Long IF Formulas with an Excel Two-Way Lookup Table
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.
Before you start

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.

Solution 1Recommended

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.

1
Add the lookup values

Enter the possible column E values in J3:J9 and the possible column B values across K2:N2.

2
Enter the results

In K3:N9, enter the text to return for each intersection of an E value and a B value.

3
Enter the 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
Fill the formula down

Drag the fill handle from G2 down column G to apply the lookup to the remaining rows.

Use INDEX and MATCH with a Two-Way Lookup Table
Exact matches are required: The 0 in each MATCH function requires an exact match. If a value from B or E is missing from the lookup headers, the formula returns #N/A.
Spreadsheet formulas

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. 1. Open your worksheet: Open the workbook in WPS Spreadsheet and select the sheet containing columns B and E.
  2. 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. 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. 4. Apply it to other rows: Drag the fill handle from G2 down to calculate results for the other rows.
Replace lengthy IF formulas with an editable lookup table.Open and edit Microsoft Excel XLSX and XLS files.Use familiar spreadsheet formulas and cell references.Update results by changing the lookup table.
QA img-9

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.