How to Use Excel MATCH Function on Two Columns
In this article
Yes, you can use the MATCH function to check if values in one column exist in another. The most common method involves using MATCH inside an IF statement to return a specific result—like "Found" or "Not Found”—or to retrieve a related value from the second column. This process requires that the two columns contain comparable data types and that the data is clean enough to match.
What You'll Need
- A computer with Microsoft Excel installed (Excel 2013 or later is recommended).
- Two columns of data in a worksheet. One column represents the "lookup" values (where you want to find matches), and the other represents the "search" values (where Excel looks for them).
- A basic understanding of formula syntax (how to type = and reference cells).
Step-by-Step
Below are the steps to check if a value in Column A exists in Column B and return the corresponding value from Column C, or indicate if it is missing. This method uses the `MATCH` function to search for a position and `IFERROR` to handle cases where no match is found.
- Open your Excel workbook. Navigate to the worksheet containing the two columns of data you wish to compare. For this guide, assume Column A contains the names you want to find, Column B contains the source list to search within, and Column C contains the addresses associated with those names.
- Select the first cell in the column where you want the results to appear. For example, if you are checking Column A, click on cell D2. This is where the formula will be entered.
- Type the following formula into the selected cell:
=IFERROR(MATCH(A2, $B$2:$B$1000, 0), "Not Found")
- Press Enter. Excel will perform the calculation immediately. If the value in cell A2 exists anywhere in the range B2:B1000, it will return the relative row number of that match. If the value is not found, it will display the text "Not Found".
- Drag the fill handle down. Click the small square in the bottom-right corner of the selected cell (D2) and drag it down to apply the formula to the rest of your dataset in Column A. Excel will automatically adjust the references for each row.
- Modify the formula to return a value instead of a number. If you want the result to be the address from Column C instead of the row number, change the formula to this:
=IFERROR(INDEX($C$2:$C$1000, MATCH(A2, $B$2:$B$1000, 0)), "Not Found")
In this formula, the `INDEX` function retrieves the value from Column C based on the row number provided by `MATCH`. The `$` symbols are crucial here; they lock the ranges so that when you drag the formula down, the search range stays fixed while the lookup value (A2) changes.
Common Mistakes
Mismatched Data Types
A frequent cause of errors is comparing different data types. For instance, searching for the number 1000 in a column of text-formatted numbers (which might appear as "1000" or 1000.00) will result in a `#N/A` error. Excel treats text and numbers as distinct values. To fix this, ensure both columns are formatted as "Number" or convert the text to numbers using the VALUE function.
Hidden Spaces
Excel often considers "John Doe " (with a trailing space) different from "John Doe" (without the space). Even a single invisible space can cause the MATCH function to fail to find a match. Use the TRIM function to clean data: `=TRIM(A2)` to remove leading, trailing, and multiple internal spaces.
Incorrect Range Locking
Forgetting to use absolute references (the dollar signs, e.g., `$B$2`) is a common error. Without them, when you drag the formula down to the next row, the search range shifts to look at the new row instead of the original list. This will return a `#N/A` error because you are searching for a value in a list that is one cell shorter than the data you are checking.
Tips
Sort Your Data for Faster Performance
If you are working with a very large dataset (thousands of rows), unsorted data will make the MATCH function execute more slowly. Sorting the search column (Column B) alphabetically or numerically can significantly improve calculation speed.
Use Exact Matching
Always ensure the third argument in the MATCH function is set to 0. This forces Excel to look for an exact match. If you omit this argument or set it to 1 or -1, Excel will attempt to find the nearest value, which can lead to incorrect results if your data is not perfectly sorted.
Troubleshooting
The formula returns #N/A
If you see the `#N/A` error, it means the value you are looking for is definitely not in the search range. Check the following:
- Typographical errors: Compare the cell visually. If you are comparing "Apple" and "Appele", they look similar but are different words.
- Data format: Check if one cell is formatted as Text and the other as General or Number. You can check this by looking at the Number Format in the Home tab.
- Hidden characters: Copy the value from the lookup column and paste it into Notepad. If there are non-printable characters, they will appear as garbage characters in Notepad. Use the CLEAN function to remove them: `=CLEAN(A2)`.
The formula returns #REF!
A `#REF!` error indicates that your formula is referencing a cell outside of the worksheet boundaries. This usually happens if you delete rows or columns within the named range while the formula is still active. To fix this, edit the formula and correct the range reference.
The formula returns a row number that seems wrong
If the result is a number, verify that you are using the `INDEX` function. The MATCH function itself only returns the position (the row number) of the item, not the item itself. If you are just using `=MATCH(A2, ...)` and see a number, it is correct behavior for that function, but you likely need to wrap it in `IFERROR` to hide the number if a match isn't found.
Frequently Asked Questions
Can I use MATCH to find a value in a horizontal list?
Yes. You can use MATCH to search across a row by specifying the row range as the second argument. For example, `=MATCH("Item", A1:Z1, 0)` will return the column number where "Item" is located.
How do I find the last match in a column?
The standard MATCH function finds the first match. To find the last occurrence, you can use the `LOOKUP` function with a large number as the lookup value, or use the `COUNTIF` function combined with MATCH to determine the position of the last match.
What is the difference between MATCH and VLOOKUP?
MATCH finds the position (row or column number) of a value within a range. VLOOKUP (Vertical Lookup) retrieves the value from a specific column based on that position. MATCH is often used inside VLOOKUP to create a dynamic lookup column number.
Why is my MATCH function case-sensitive?
By default, the MATCH function in Excel is not case-sensitive. It treats "Apple" and "apple" as the same value. To make it case-sensitive, you must use the `SUMPRODUCT` or `COUNTIF` functions combined with the `EXACT` function, as MATCH does not have a case-sensitive switch.
Can I use MATCH with wildcards like * or ?
Yes, the MATCH function supports wildcards. Using `*` matches any sequence of characters, and `?` matches any single character. For example, `=MATCH("J*", A:A, 0)` will find the first cell in column A that starts with the letter "J".