=SEARCH()
The SEARCH function locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. For example, to find the position of the letter "n" in the word "printer", you can use the following function: =SEARCH("n","printer") This function returns 4 because "n" is the fourth character in the word "printer." You can also search for words within other words. For example, the function =SEARCH("base","database") returns 5, because the word "base" begins at the fifth character of the word "database". You can use the SEARCH to determine the location of a character or text string within another text string, and then use the MID to return the text, or use the REPLACE to change the text. These functions are demonstrated in Example 1 in this article.
=SEARCH(find_text,within_text,[start_num])
⬇ Download Sample Workbook
A dedicated .xlsx for =SEARCH() with Persian sample data & live formulas — open in Excel and practice.
- Sheet “Sample” — data table + formula in place
- Sheet “Guide” — syntax, arguments & tips from this page
- Instant & secure (token + rate limit)
Quiz this function
%d questions — syntax, example & errors — test yourself!
◧ Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
find_text |
Any type | Required | The text that you want to find. |
within_text |
Any type | Required | The text in which you want to search for the value of the |
start_num |
Any type | Optional | The character number in the |
▣ Examples
| Cell | Value |
|---|---|
A2 |
Statements |
A3 |
Profit Margin |
A4 |
margin |
A5 |
The "boss" is here. |
A6 |
Statements |
A7 |
Profit Margin |
A8 |
margin |
A9 |
The "boss" is here. |
=SEARCH("e",A2,6)
=SEARCH(A4,A3)
=REPLACE(A3,SEARCH(A4,A3),6,"Amount")
=MID(A3,SEARCH(" ",A3)+1,4)
=SEARCH("""",A5)
=MID(A5,SEARCH("""",A5)+1,SEARCH("""",A5,SEARCH("""",A5)+1)-SEARCH("""",A5)-1)
✦ Tips
- The SEARCHB function is deprecated. In workbooks set to Compatibility Version 2, SEARCH has improved behavior with Surrogate Pairs, counting them as one character instead of two. Variation Selectors (commonly used with emojis) will still be counted as separate characters. Read more here: The Unicode standard
💬 Comments & Q&A 0 approved
🔒 Your comment will be published after review.Share your thoughts — visible after admin approval