Text All versions ◉ 33 views

=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.

Applies To: Excel for Microsoft 365Excel for Microsoft 365 for MacExcel 2024Excel 2024 for MacExcel 2021Excel 2021 for MacExcel 2019Excel 2016
=SEARCH(find_text,within_text,[start_num])
Hover argument names in the table for details.
Output typeNumber
Popularity60 / 100
VolatileNo
Dynamic ArrayNo
Download sample .xlsx ▦ Try in Playground Dedicated file for this function — safe & lightweight · sample data + live formulas
Share:

⬇ 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)
Download SEARCH.xlsx ~ 8–12 KB · No macros

⇪ Share

Send this function to friends

Quiz this function

%d questions — syntax, example & errors — test yourself!

◧ Arguments

ArgumentTypeRequiredDescription
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

▦ Data
CellValue
A2 Statements
A3 Profit Margin
A4 margin
A5 The "boss" is here.
A6 Statements
A7 Profit Margin
A8 margin
A9 The "boss" is here.
Position of the first "e" in the string in cell A2, starting at the sixth position. =SEARCH("e",A2,6)
Result: 7
Position of "margin" (string for which to search is cell A4) in "Profit Margin" (cell in which to search is A3). =SEARCH(A4,A3)
Result: 8
Replaces "Margin" with "Amount" by first searching for the position of "Margin" in cell A3, and then replacing that character and the next five characters with the string "Amount." =REPLACE(A3,SEARCH(A4,A3),6,"Amount")
Result: Profit Amount
Returns the first four characters that follow the first space character in "Profit Margin" (cell A3). =MID(A3,SEARCH(" ",A3)+1,4)
Result: Marg
Position of the first double quotation mark (") in cell A5. =SEARCH("""",A5)
Result: 5
Returns only the text enclosed in the double quotation marks in cell A5. =MID(A5,SEARCH("""",A5)+1,SEARCH("""",A5,SEARCH("""",A5)+1)-SEARCH("""",A5)-1)
Result: boss

✦ 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

No comments yet — be the first!

✍️ Add comment / question

captcha
🔒 Your comment will be published after review.