Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets MATCH Function: How to Use It Correctly

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The Google Sheets MATCH function returns the relative position of a specified item in a range of cells. Unlike VLOOKUP, which retrieves data based on a lookup value, MATCH only tells you where that value is located within your chosen column or row. This makes it an essential tool for dynamic formulas, particularly when combined with INDEX to create flexible lookups that do not break if you insert or delete columns.

What You'll Need

  • A Google Sheets document with at least one column or row of data to search.
  • A specific value you want to find (the search_key).
  • Basic understanding of cell references (e.g., A1, B2) and ranges (e.g., A1:A10).

Step-by-Step

  1. Select the target cell. Click on the empty cell where you want the result (the position number) to appear. For this example, assume you are looking for a name in column A and want the result in cell C1.
  2. Type the function start. Enter =MATCH( into the cell. Do not close the parenthesis yet.
  3. Define the search key. Specify the value you are looking for. This can be a direct text string enclosed in quotes (e.g., "Apple") or a reference to another cell containing the value (e.g., B1). If using a cell reference, ensure that cell contains the exact value you want to match. Type a comma after this argument.
  4. Select the lookup array. Highlight the range of cells you want to search. For vertical lookups, select a single column (e.g., A2:A100). For horizontal lookups, select a single row (e.g., A1:E1). Ensure the range does not include headers if you want the count to start from the first data entry, or adjust your expectation accordingly. Type a comma after this argument.
  5. Choose the match type. The third argument determines how the function searches. Common options are:
    • 0: Exact match. The function looks for the exact value. If not found, it returns #N/A.
    • 1: Less than or equal to. Assumes the lookup array is sorted in ascending order. Returns the largest value less than or equal to the search key.
    • -1: Greater than or equal to. Assumes the lookup array is sorted in descending order. Returns the smallest value greater than or equal to the search key.
    For most basic tasks, use 0. Type 0) to close the formula.
  6. Press Enter. The cell will display the relative position of the item within the selected range. If "Apple" is the third item in your selected range A2:A100, the result will be 3.

Common Mistakes

One frequent error is mismatching the orientation of the lookup array. MATCH works on a single row or a single column. If you select a multi-column range like A1:C10, the function will return an error because it cannot determine a single linear position. Always restrict your selection to one dimension.

Another common issue involves the match type argument. Using 1 or -1 without sorting the data leads to incorrect results. If your data is unsorted, you must use 0 for an exact match. Additionally, users often forget that MATCH returns a position number, not the actual value. If you need the value itself, you must combine MATCH with INDEX.

Case sensitivity is also a point of confusion. By default, MATCH is case-insensitive. "apple" and "Apple" are treated as the same. If you require case-sensitive matching, you need to use more complex array formulas involving EXACT, which is beyond the scope of the standard MATCH function.

Tips

Combine MATCH with INDEX to create a powerful alternative to VLOOKUP. The formula =INDEX(A:A, MATCH("Apple", B:B, 0)) looks for "Apple" in column B and returns the corresponding value from column A. This method is more robust because it does not break if you insert new columns between your lookup and return ranges.

Use absolute references for your lookup arrays if you plan to copy the formula down multiple rows. For example, change A2:A100 to $A$2:$A$100. This ensures the search range remains fixed while the search key changes for each row.

If you are searching for a value that might not exist, wrap the MATCH function in IFERROR to provide a cleaner output. For instance, =IFERROR(MATCH("Orange", A:A, 0), "Not Found") will display "Not Found" instead of the #N/A error message.

Troubleshooting

If you receive a #N/A error, it means the search key was not found in the lookup array. Double-check for typos in the search key. Also, verify that there are no extra spaces in the data. Leading or trailing spaces will cause an exact match to fail. You can use the TRIM function on your source data to remove these invisible characters.

A #VALUE! error usually indicates that the lookup array is not a single row or column. Check your range selection to ensure it is one-dimensional. If you accidentally selected a block of cells, resize the range to cover only one column or one row.

If the result seems off by one, consider whether your range includes headers. If you select A1:A10 and A1 is a header, but you are searching for data starting in A2, the position returned will be relative to A1. To fix this, either exclude the header from the range (start at A2) or subtract 1 from the result if you need the position relative to the data start.

Ensure your locale settings support the function syntax. In some regions, Google Sheets uses semicolons (;) instead of commas (,) to separate arguments. If your formula fails immediately, try replacing commas with semicolons.

Frequently Asked Questions

Can MATCH search across multiple columns?

No, the standard MATCH function only searches within a single row or a single column. To search across multiple columns, you would need to use an array formula combining MATCH with other functions, or restructure your data so the search values are in a single column.

Is MATCH case-sensitive?

No, MATCH is not case-sensitive. It treats uppercase and lowercase letters as identical. If you need case-sensitive matching, you must use a different approach, such as combining INDEX, MATCH, and EXACT in an array formula.

Why does my MATCH return #REF!?

A #REF! error typically occurs if the range referenced in the formula has been deleted or moved. Check that the cells in your lookup array still exist and have not been removed from the sheet.

How is MATCH different from COUNTIF?

COUNTIF counts how many times a value appears in a range, returning a total number. MATCH finds the position of the first occurrence of a value, returning the index number. They serve different purposes: counting versus locating.

Can I use wildcards in MATCH?

Yes, if you set the match type to 0, you can use wildcards. An asterisk (*) represents any sequence of characters, and a question mark (?) represents a single character. For example, searching for "App*" will find "Apple," "Application," etc.