The SEARCH function searches for and returns the location of one text value in another text value. The search is not case-sensitive, traverses the text value being searched from left to right and begins from the character whose position matches the value passed to the start_num argument. It ends either (1) when the first instance of the text value being searched for is discovered, or (2) the end of the text value being searched is reached. Upon discovering the first instance of the text value being searched for, the SEARCH function returns a whole number whose value is ≥ 1, which represents the position of its first character in the text value that was searched. #VALUE! is returned if the search fails to discover any instances of a text value being searched for.
The formula instructs the SEARCH function to search the text value “ABC dEf ABC DeF” for instances of “def” and to begin its search from the ninth character (“A“). Starting with this character, 3 characters are retrieved (“ABC“). “ABC” and “def” are not equal and another 3 characters are retrieved starting from the tenth character (“BC “) and they are compared to “def“. This process of retrieving 3 characters and performing a case-insensitive comparison between them and “def” repeats until either a match is found or it isn’t possible to retrieve 3 characters. Each time the process repeats, the starting character is moved one position to the right. The process is illustrated below:
A text value that will be searched for in the value supplied to the within_text argument. the SEARCH function permits two wildcard characters and two escape sequences to appear in find_text. They are described in the table below.
Value
Description
*
Represents any sequence of characters of any length. For example, “a*f” will match with a text value beginning with “a“, followed by any sequence of characters of any length and ending with “f“.
?
Represents any one character. For example, “a?f” will match with a text value beginning with “a“, followed by any character and ending with “f“.
~*
An escape sequence which matches the character “*“. For example, “a~*b” matches text value “a*b“.
~?
An escape sequence which matches the character “?“. For example, “a~?b” matches text value “a?b“.
within_text
Mandatory
A text value searched for instances of the value supplied to the find_text argument.
start_num
Optional. Defaults to 1 if omitted.
The position of the character in within_text from which the search for find_text will begin.
Its purpose is identical to that of the SEARCH function: the FIND function searches for and returns the location of one text value in another text value. FIND differs from SEARCH in that it performs case-sensitive searches and does not support wildcards.