Excel - SEARCH Function



SEARCH Function

The EXCEL SEARCH function returns an integer representing the location of the substring inspected in another text string. The text is searched from left to right and is not case-sensitive. It is contrary to the SEARCHB function. For example, Searching the text innovative creator in the millions of records of the editorial dataset, dynamic searching, and extracting the ISD codes of phone numbers utilizing the LEFT and SEARCH functions. This master function saves your precious time and streamlines the search strategy.

Compatibility

The SEARCH function is compatible with multiple versions of MS Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016

Syntax

The Syntax of the SEARCH function is as follows −

=SEARCH(find_text,within_text,[start_num])

Arguments

You can utilize the following arguments with the SEARCH function −

Argument Description Required / Optional
find_text A text string that needs to be searched in the within_text argument. Required
within_text Other string in which the find_texts value is being searched. Required
[start_num] It indicates the starting position of the text to start the search. Optional

Points to Remember

  • The SEARCH function will retrieve the #VALUE! error if the text/character defined in the find_text is unavailable in the within_text arguments value.
  • The find_text may include wild cards like (*) and (?) characters.
  • The SEARCH function retrieves the #VALUE! error if the cell reference is given the find_text argument.
  • By default, the start_num value is 1, which means searching for text in the targeted string begins from the front side.
  • The SEARCH function will get the #VALUE! error if the start_num contains a nonpositive value or is greater than the length of within_text.

Examples of SEARCH Function

Practice the following example to learn the use of the SEARCH function in Excel.

Example 1: How to use the Search Function?

The SEARCH function is used to find the position of a substring within another string.

Solution

Step 1 − Consider the sample dataset where the substring and input text values are specified in the C2 and C3 cells.

SEARCH Function

Step 2 − Enter the formula =SEARCH("Aptos",C3) in the C4 cell and hit the Enter tab.

SEARCH Function 1

Therefore, the index position of the Aptos is 18.

SEARCH Function 2

Using Wildcard Characters

Suppose you want to extract the character's position before the e character. In this scenario, you can write the formula =SEARCH("?e",C3) in the C5 cell.

SEARCH Function 3

Therefore, the SEARCH function will retrieve the 11, which is the index position of the g character.

Example 2

Extracting ISD Codes for Different Countries in Hotline Numbers

Solution

Step 1 − Consider the sample dataset, which has a list of hotline numbers in the B column. Use the LEFT and SEARCH functions to populate the ISD code only in the C column.

ISD Codes for Different Countries

Step 2 − Write the formula =LEFT(B2, SEARCH(" ", B2) -1) in the C2 cell.

ISD Codes for Different Countries 1

Explanation

=LEFT(B2, SEARCH(" ", B2) -1)
  • The SEARCH(" ", B2) function will extract the position of the empty space, which is three.
  • The LEFT(B2, SEARCH(" ", B2) -1) function will retrieve the numbers till space.

Once you press the Enter tab, the result is 91, an ISD code.

ISD Codes for Different Countries 2

Step 3 − Similarly, drag the fill handle(+) sign located at the bottom right corner in the C2 cell and place it in the C8 cell to compute the ISD code downwards.

ISD Codes for Different Countries 3

Download Practice Sheet

You can download and use the sample data sheet to practice the SEARCH function.

Advertisements