Yes, you can find a string inside a vertical or horizontal array in Excel. The most direct way is using the INDEX(MATCH(...)) combination. This looks through the array for a specific text value (the string) and returns the relative position of that item. Once you have the position, you can use that number to pull the full row or column, or to return a specific piece of data associated with the string. Alternatively, the TEXTJOIN(IF(...)) method allows you to scan an array and join together every cell that contains your target string into a single list.

What You'll Need

  • A spreadsheet application, such as Microsoft Excel (Desktop or Online) or Google Sheets.
  • A dataset (a list, table, or range of cells) containing the text values you want to search through.
  • A target string (the specific text you are looking for).
  • Basic knowledge of spreadsheet functions like INDEX, MATCH, and IF.

Step-by-Step

Method 1: Finding the Position (INDEX and MATCH)

This method is best if you want to know where a specific item is located within your data or to use that location to fetch a related value.

  1. Identify your data array. This is the range of cells that contains the list of items you want to search. For example, if your list is in cells A2:A20, your array range is A2:A20.
  2. Identify the target string. This is the text you are looking for. It should be in a single cell, say B2. This makes the formula easier to edit and test.
  3. Open a new cell. Click on the cell where you want the result to appear.
  4. Enter the MATCH function. Type =MATCH( to start the formula. This function finds the relative position of an item in a range.
  5. Specify the lookup value. For the first argument, click on the cell containing your target string (e.g., B2). Alternatively, you can type the text directly inside the parentheses, like "Apple". Close this argument with a comma ,.
  6. Specify the lookup array. For the second argument, select the range of cells you identified in step 1 (e.g., A2:A20). This tells Excel where to look for the text. Close this argument with a comma ,.
  7. Specify the match type. For the third argument, type 0. This tells Excel to find an exact match. Do not leave this blank or use 1 or -1, as it will return the nearest match, which may be incorrect for text strings. Close the function with a closing parenthesis ).
  8. Combine with INDEX. Immediately after the closing parenthesis of the MATCH function, type a comma , and then the INDEX function: =INDEX(.
  9. Specify the array argument for INDEX. For this argument, you can either repeat the array you searched (e.g., A2:A20) or, if your goal is to return the full row of data, you can select a much larger range that includes your search range and the columns you want to extract. For example, if you want to return the full row of data for the found item, you might use A1:D20. Close this argument with a comma ,.
  10. Specify the row number. This is the number returned by the MATCH function. In your formula, this will be the entire MATCH function you just built. Close the INDEX function with a closing parenthesis ).
  11. Press Enter. The cell will now display the result, which is the item from the array at the position found by MATCH.

Method 2: Extracting and Joining Matching Strings (TEXTJOIN and IF)

This method is ideal when you have a list of items and you want to collect all of them that contain a specific word or phrase, creating a new list of results.

  1. Identify your data array. This is the range of cells containing the data you want to search through. For example, A2:A100.
  2. Identify the target string. This is the text you are searching for. It can be in a cell like C2 or typed directly into the formula.
  3. Open a new cell. Click on the cell where you want the combined list of results to appear.
  4. Enter the TEXTJOIN function. Type =TEXTJOIN(. This function takes a collection of text and combines them into one string.
  5. Specify the delimiter. For the first argument, type a character that separates your results. Common delimiters are a comma and a space ", " or a semicolon ";". Close this argument with a comma ,.
  6. Enter the IF function. Immediately after the delimiter argument, type a comma , and then type IF(. This function performs a logical test.
  7. Enter the logical test. For the first argument of IF, check if each cell in your data array contains the target string. Use the ISNUMBER functionality combined with SEARCH. Type ISNUMBER(SEARCH(. This combination returns TRUE if the string is found anywhere within the cell's text.
  8. Specify the lookup value. Inside the SEARCH function, type the target string (e.g., C2). Close this argument with a comma ,.
  9. Specify the lookup array. Inside the SEARCH function, select your data array (e.g., A2:A100). Close the SEARCH function with a closing parenthesis ). The SEARCH function is now complete.
  10. Specify the value if true. For the second argument of IF, type the text you want to extract if the condition is met. This is the original cell from your data array (e.g., A2). Close this argument with a comma ,.
  11. Specify the value if false. For the third argument of IF, type "" (an empty string). This ensures that cells that do not contain the target string contribute nothing to the final list.
  12. Close the IF function and the TEXTJOIN function. Close the IF function with a closing parenthesis ). Then, close the TEXTJOIN function with a final closing parenthesis ).
  13. Press Enter. The cell will now contain a list of all items from the array that contained the target string, separated by your chosen delimiter.

Common Mistakes

  • Incorrect Match Type in MATCH. A frequent error is leaving the third argument of the MATCH function blank or using 1 or -1. This instructs Excel to find an approximate match based on the array's order. For text, this will often return the wrong item or an error. Always use 0 for an exact match.
  • Using VLOOKUP Instead of MATCH. The VLOOKUP function is rigid; it can only look to the right of the lookup column. If your data is not perfectly organized with the item you are searching for in the first column of a range, VLOOKUP will fail. MATCH is much more flexible as it only finds the position and does not care about the columns to the left.
  • Incorrect Array References in INDEX. When using INDEX to return a full row or column, ensure the array reference includes the entire range you intend to work with. If you search in A2:A10 but your INDEX array is only A2:A10, you will only get the first column of data back. To get the whole row, the array must span all columns you want to extract.
  • Forgetting to Lock Ranges. When dragging a formula down a column, the cell references will shift. If you want to search the same fixed list of data for different target strings, you must use absolute references (e.g., $A$2:$A$100) so the search range does not change as you move the formula.

Tips

  • Case Sensitivity. By default, the SEARCH function is not case-sensitive. It will find "Apple" in "apple pie" and "APPLE JUICE". If you need a case-sensitive search, use the FIND function instead. This will only match the string with the exact same capitalization.
  • Wildcards in SEARCH. The SEARCH function supports wildcards, which makes it very powerful. The asterisk * represents any number of characters, and the question mark ? represents a single character. You can use this to find strings that share a common prefix or suffix. For example, searching for *phone will find "iPhone" and "Landline".
  • Handle Errors Gracefully. If the MATCH function cannot find the target string, it will return the #N/A error. You can wrap the MATCH function in an IFERROR function to display a more user-friendly message, such as IFERROR(INDEX(... MATCH(...)), "Not Found"). This prevents the error from propagating to other cells that might be using the result of your formula.
  • Use Table Names. If your data is in an official Excel Table (created via Insert > Table), you can use the table's name in your formulas. This makes your formulas much more readable and self-explanatory, as the range A2:A100 becomes TableName[ColumnName].

Troubleshooting

When your formula returns an error or an unexpected result, the issue is almost always one of three things: the data format, the reference scope, or the logic of the search.

Problem: The formula returns #N/A. This is the most common error with the MATCH function. It means Excel could not find the exact text you specified in the range you provided. To fix this, check the following:

  • Hidden Characters or Spaces. The target string and the items in the array might look identical to the eye, but one or both could have trailing spaces or invisible formatting characters. For example, searching for "Apple " (with a space at the end) will fail to find "Apple" in the array. Use the TRIM function on your data before searching to remove these unwanted spaces.
  • Data Type Mismatch. Ensure that the cell containing your target string is formatted as text. If it is formatted as a number, searching for a word will fail. You can often see this by looking at the number format in the Home tab of the ribbon. If it is General or Number, change it to Text.
  • Exact Text Match. Double-check that the text in the target cell is exactly the same as the text in the array. Even a single character difference, such as a hyphen - versus an underscore _, will cause a #N/A error.

Problem: The TEXTJOIN formula returns a result but omits some items you expected to find. This usually happens if the search is too broad or too narrow.

  • Too Broad. If you are using wildcard characters like * (any characters) or ? (one character), you might be matching parts of words you didn't intend to. For example, searching for "cat" will also match "catalog" and "scatter" because the letters "cat" appear at the start of those words. If you want to match whole words only, you will need a more complex formula, as basic SEARCH does not support word boundaries.
  • Too Narrow. Ensure that your target string is not longer than the cells you are searching. If you are searching for a 10-character phrase, it will not be found in a cell that only contains a 5-character word.

Problem: The formula is not updating when I change the target string. This is a classic issue with absolute vs. relative referencing.

  • Fix the References. If you want to drag the formula down a column to search the same list of data for different target strings, you must ensure the lookup array in MATCH (or the data array in TEXTJOIN) is locked. Change the range reference from A2:A100 to $A$2:$A$100. The dollar signs $ tell Excel to treat that specific cell or range as permanent, even when the formula is copied or dragged to a new location.

Frequently Asked Questions

Can I use this method with a horizontal array?

Yes. The INDEX, MATCH, and TEXTJOIN functions all work with horizontal arrays just as well as vertical ones. For a horizontal array, such as B2:K2, you would simply select that range as your array argument. The logic remains the same: MATCH finds the relative position (e.g., 3 means the third item in that row), and INDEX or TEXTJOIN uses that position to return data.

What is the difference between FIND and SEARCH?

The primary difference is case sensitivity. The SEARCH function is not case-sensitive, meaning it will find "apple" in "Apple Pie" regardless of capitalization. The FIND function is case-sensitive and will only return a match if the case of the letters matches exactly. Additionally, FIND does not support wildcards like * or ? in older versions of Excel, whereas SEARCH does.

Will this work if the string appears multiple times in the array?

Yes. The MATCH function will return the position of the first occurrence of the string it finds. If your goal is to get a list of all occurrences, the standard MATCH function is not sufficient. You would need to use a more advanced array formula or a VBA script to iterate through the array and collect every instance.

How do I handle errors if the string is not found?

To prevent the #N/A error from breaking your spreadsheet, you can wrap your formula in an IFERROR function. The syntax looks like this: =IFERROR(MATCH(...), "Not Found"). This tells Excel to display the text "Not Found" if the MATCH function returns an error, and to display the normal result if it finds a match.

Can I search for a string within a single cell?

Yes, you can search for a string within a single cell. The SEARCH function is designed to look for a substring within a larger string. For example, if cell A1 contains "The quick brown fox", searching for SEARCH("fox", A1) will return the number 16, indicating that "fox" starts at the 16th character of that cell.

Does this work in Google Sheets?

Yes, the functions INDEX, MATCH, TEXTJOIN, IF, and SEARCH are all fully supported in Google Sheets. The syntax is identical to that used in Microsoft Excel. You can use these methods to find strings in arrays within Google Sheets just as you would in a desktop version of Excel.