The tutorial explains the syntax of the Excel FIND and SEARCH functions and provides formula examples of advanced non-trivial uses.
In the last article, we covered the basics of the Excel Find and Replace dialog. In many situations, however, you may want Excel to find and extract data from other cells automatically based on your criteria. So, let's have a closer look at what the Excel search functions have to offer.
Excel FIND function
The FIND function in Excel is used to return the position of a specific character or substring within a text string.
The syntax of the Excel Find function is as follows:
The first 2 arguments are required, the last one is optional.
- Find_text - the character or substring you want to find.
- Within_text - the text string to be searched within. Usually it's supplied as a cell reference, but you can also type the string directly in the formula.
- Start_num - an optional argument that specifies from which character the search shall begin. If omitted, the search starts from the 1st character of the within_text string.
If the FIND function does not find the find_text character(s), a #VALUE! error is returned.
For example, the formula =FIND("d", "find")
returns 4 because "d" is the 4th letter in the word "find". The formula =FIND("a", "find")
returns an error because there is no "a" in "find".
Excel FIND function - things to remember!
To correctly use a FIND formula in Excel, keep in mind the following simple facts:
- The FIND function is case sensitive. If you are looking for a case-insensitive match, use the SEARCH function.
- The FIND function in Excel does not allow using wildcard characters.
- If the find_text argument contains several characters, the FIND function returns the position of the first character. For example, the formula FIND("ap","happy") returns 2 because "a" in the 2nd letter in the word "happy".
- If within_text contains several occurrences of find_text, the first occurrence is returned. For example, FIND("l", "hello") returns 3, which is the position of the first "l" character in the word "hello".
- If find_text is an empty string "", the Excel FIND formula returns the first character in the search string.
- The Excel FIND function returns the #VALUE! error if any of the following occurs:
- Find_text does not exist in within_text.
- Start_num contains more characters than within_text.
- Start_num is 0 (zero) or a negative number.
Excel SEARCH function
The SEARCH function in Excel is very similar to FIND in that it also returns the location of a substring in a text string. Is syntax and arguments are akin to those of FIND:
Unlike FIND, the SEARCH function is case-insensitive and it allows using the wildcard characters, as demonstrated in the following example.
And here's a couple of basic Excel SEARCH formulas:
=SEARCH("market", "supermarket")
returns 6 because the substring "market" begins at the 6th character of the word "supermarket".
=SEARCH("e", "Excel")
returns 1 because "e" is the first character in the word "Excel", ignoring the case.
Like FIND, Excel's SEARCH function returns the #VALUE! error if:
- The value of the find_text argument is not found.
- The start_num argument is greater than the length of within_text.
- Start_num is equal to or less than zero.
Further on in this tutorial, you will find a few more meaningful formula examples that demonstrate how to use SEARCH function in Excel worksheets.
Excel FIND vs. Excel SEARCH
As already mentioned, the FIND and SEARCH functions in Excel are very much alike in terms of syntax and uses. However, they do have a couple of differences.
1. Case-sensitive FIND vs. case-insensitive SEARCH
The most essential difference between the Excel SEARCH and FIND functions is that SEARCH is case-insensitive, while FIND is case-sensitive.
For example, SEARCH("e", "Excel") returns 1 because it ignores the case of "E", while FIND("e", "Excel") returns 4 because it minds the case.
2. Search with wildcard characters
Unlike FIND, the Excel SEARCH function accepts wildcard characters in the find_text argument:
- A question mark (?) matches one character, and
- An asterisk (*) matches any series of characters.
To see how it works on real data, consider the following example:
As you see in the screenshot above, the formula SEARCH("function*2013", A2) returns the position of the first character ("f") in the substring if the text string referred to in the within_text argument contains both "function" and "2013", no matter how many other characters there are in between.
Tip. To find an actual question mark (?) or asterisk (*), type a tilde (~) before the corresponding character.
Excel FIND and SEARCH formula examples
In practice, the Excel FIND and SEARCH functions are rarely used on their own. Typically, you would utilize them in combination with other functions such as MID, LEFT or RIGHT, and the following formula examples demonstrate some real-life uses.
Example 1. Find a string preceding or following a given character
This example shows how you can find and extract all characters in a text string to the left or to the right of a specific character. To make things easier to understand, consider the following example.
Supposing you have a column of names (column A) and you want to pull the First name and Last name into separate columns.
To get the first name, you can use FIND (or SEARCH) in conjunction with the LEFT function:
=LEFT(A2, FIND(" ", A2)-1)
or
=LEFT(A2, SEARCH(" ", A2)-1)
As you probably know, the Excel LEFT function returns the specified number of left-most characters in a string. And you use the FIND function to determine the position of a space (" ") to let the LEFT function know how many characters to extract. At that, you subtract 1 from the space's position because you don't want the returned value to include the space.
To extract the last name, use the combination of the RIGHT, FIND / SEARCH and LEN functions. The LEN function is needed to get the total number of characters in the string, from which you subtract the position of the space:
=RIGHT(A2,LEN(A2)-FIND(" ",A2))
or
=RIGHT(A2,LEN(A2)-SEARCH(" ",A2))
The following screenshot demonstrates the result:
For more complex scenarios, such as extracting a middle name or splitting names with suffixes, please see How to split cells in Excel using formulas.
Example 2. Find Nth occurrence of a given character in a text string
Supposing you have some text strings in column A, say a list of SKUs, and you want to find the position of the 2nd dash in a string. The following formula works a treat:
=FIND("-", A2, FIND("-",A2)+1)
The first two arguments are easy to interpret: locate a dash ("-") in cell A2. In the third argument (start_num), you embed another FIND function that tells Excel to start searching beginning with the character that comes right after the first occurrence of dash (FIND("-",A2)+1).
To return the position of the 3rd occurrence, you embed the above formula in the start_num argument of another FIND function and add 2 to the returned value:
=FIND("-",A2, FIND("-", A2, FIND("-",A2)+1) +2)
Another and probably a simpler way of finding the Nth occurrence of a given character is using the Excel FIND function in combination with CHAR and SUBSTITUTE:
=FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),3))
Where "-" is the character in question and "3" is the Nth occurrence you want to find.
In the above formula, the SUBSTITUTE function replaces the 3rd occurrence of dash ("-") with CHAR(1), which is the unprintable "Start of Heading" character in the ASCII system. Instead of CHAR(1) you can use any other unprintable character from 1 to 31. And then, the FIND function returns the position of that character in the text string. So, the general formula is as follows:
At first sight, it may seem that the above formulas have little practical value, but the next example will show how useful they are in solving real tasks.
Note. Please remember that the Excel FIND function is case-sensitive. In our example, this makes no difference, but if you are working with letters and you want a case-insensitive match, use the SEARCH function instead of FIND.
Example 3. Extract N characters following a certain character
To locate a substring of a given length within any text string, use Excel FIND or Excel SEARCH in combination with the MID function. The following example demonstrates how you can use such formulas in practice.
In our list of SKUs, supposing you want to find the first 3 characters following the first dash and pull them in another column.
If the group of characters preceding the first dash always contains the same number of items (e.g. 2 chars) this would be a trivial task. You could use the MID function to return 3 characters from a string, starting at position 4 (skipping the first 2 characters and a dash):
=MID(A2, 4, 3)
Translated into English, the formula says: "Look in cell A2, begin extracting from character 4, and return 3 characters".
However, in real-life worksheets, the substring you need to extract could start anywhere within the text string. In our example, you may not know how many characters precede the first dash. To cope with this challenge, use the FIND function to determine the starting point of the substring that you want to retrieve.
The FIND formula to return the position of the 1st dash is as follows:
=FIND("-",A2)
Because you want to start with the character that follows the dash, add 1 to the returned value and embed the above function in the second argument (start_num) of the MID function:
=MID(A2, FIND("-",A2)+1, 3)
In this scenario, the Excel SEARCH function works equally well:
=MID(A2, SEARCH("-",A2)+1, 3)
It's great, but what if the group of chars following the first dash contains a different number of characters? Hmm... this might be a problem:
As you see in the above screenshot, the formula works perfectly for rows 1 and 2. In rows 4 and 5, the second group contains 4 characters, but only the first 3 chars are returned. In rows 6 and 7, there are only 2 characters in the second group, and therefore our Excel Search formula returns a dash following them.
If you wanted to return all chars between the 1st and 2nd occurrences of a certain character (dash in this example), how would you proceed? Here is the answer:
=MID(A2, FIND("-",A2)+1, FIND("-", A2, FIND("-",A2)+1) - FIND("-",A2)-1)
For better understanding of this MID formula, let's examine its arguments one by one:
- 1st argument (text). It's the text string containing the characters you want to extract, cell A2 in this example.
- 2nd argument (start_position). Specifies the position of the first character you want to extract. You use the FIND function to locate the first dash in the string and add 1 to that value because you want to start with the character that follows the dash: FIND("-",A2)+1.
- 3rd argument (num_chars). Specifies the number of characters you want to return. In our formula, this is the trickiest part. You use two FIND (or SEARCH) functions, one determines the position of the first dash: FIND("-",A2). And the other returns the position of the second dash: FIND("-", A2, FIND("-",A2)+1). Then you subtract the former from the latter, and then subtract 1 because you don't want to include either dash. As the result, you will get the number of characters between the 1st and 2nd dashes, which is exactly what we are looking for. So, you feed that value to the num_chars argument of the MID function.
In a similar fashion, you can return 3 characters after the 2nd dash:
=MID(A2, FIND("-",A2, FIND("-", A2, FIND("-",A2)+1) +2), 3)
Or, extract all the characters between the 2nd and 3rd dashes:
=MID(A2, FIND("-", A2, FIND("-",A2)+1)+1, FIND("-",A2, FIND("-", A2, FIND("-",A2)+1) +2) - FIND("-", A2, FIND("-",A2)+1)-1)
Example 4. Find text between parentheses
Supposing you have some long text string in column A and you want to find and extract only the text enclosed in (parentheses).
To do this, you would need the MID function to return the desired number of characters from a string, and either Excel FIND or SEARCH function to determine where to start and how many characters to extract.
=MID(A2,SEARCH("(",A2)+1, SEARCH(")",A2)-SEARCH("(",A2)-1)
The logic of this formula is similar to the ones we discussed in the previous example. And again, the most complex part is the last argument that tells the formula how many characters to return. That pretty long expression in the num_chars argument does the following:
- First, you find the position of the closing parenthesis:
SEARCH(")",A2)
- After that you locate the position of the opening parenthesis:
SEARCH("(",A2)
- And then, you calculate the difference between the positions of the closing and opening parentheses and subtract 1 from that number, because you don't want either parenthesis in the result:
SEARCH(")",A2)-SEARCH("(",A2))-1
Naturally, nothing prevents you from using the Excel FIND function instead of SEARCH, because case-sensitivity or case-insensitivity makes no difference in this example.
Hopefully, this tutorial has shed some light on how to use SEARCH and FIND functions in Excel. In the next tutorial, we are going to closely examine the REPLACE function, so please stay tuned. Thank you for reading!
440 comments
How can I find a character and count the total of them in a whole spreadsheet for example I want to find how many "x" in the whole spreadsheet.
Hello!
I recommend reading this guide: How to count characters in Excel.
It contains answers to your question.
Hello
I have read through your comments but could not find what I am looking for.
What I am trying to do is extract the following text "Technical" from a subject heading such as:
Non-Confidential - Technical : Investigations
Confidential - Technical : Meeting
Is there a formula that picks up the text between "-" and ":" that will extract the text "Technical"?
Look forward to your response.
Thanks,
Marty
Hello!
If I understand your task correctly, the following formula should work for you:
=MID(A2,FIND("–",A2)+1,FIND(":",A2)-FIND("–",A2)-1)
We have a tool that can solve your task in a couple of clicks. This is the Extract text tool. It can extract text from a cell by pattern and in many other ways. It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.
Hi,
I have had a look through all the great questions / answers but can't find one that fits my question.
I have a number of server names which i want to remove extra characters such as:-
LWWITE13(VG) - Remove (VG)
HLHDDI02_DR - Remove _DR
PORTING-VIOS - removed _VOS
DC3_ESX_LWUKHYPTC02 - Removed DC3_ESX
At the moment i use this formula and then amending ,FIND("(", for each line i find.
=IFERROR(LEFT(A13,FIND("_",A13)-1),A13)
But wanted to understand if there was a way of creating a formula's that covers them all?
Appreciate your help
Paula
Hello!
For the first three values, you can use the formula
=LEFT(A1,MAX(IFERROR(SEARCH({"(";"-";"_"},A1,1),0))-1)
For the fourth value, try the formula
=MID(MID(A1,MAX(IFERROR(SEARCH({"(";"-";"_"},A1),0))+1,100), MAX(IFERROR(SEARCH({"(";"-";"_"}, MID(A1, MAX(IFERROR(SEARCH({"(";"-";"_"},A1),0))+1,100)),0))+1,100)
I hope it’ll be helpful.
Dear Sir,
Please help me with a formula which returns complete value with specific Text like in following table data contain 7 entries with different months, any formula here I can use to search all entries and return complete value which contain text "MAY".
Data
A1 A-MAY212
A2 B-MARCH212
A3 C-APRIL213
A4 D-APRIL214
A5 E-JUNE215
A6 F-JULY216
A7 A-MAY217
Result
A-MAY212
A-MAY217
Thanks
Hi!
I believe the following formula will help you solve your task:
=FILTER(A1:A9, ISNUMBER(SEARCH("MAY",A1:A9)), "")
You can learn more about FILTER function in Excel in this article on our blog.
Respected Sir,
I have the following text in A1 Cell
1 «kht¼{kt Eïhu ykfkþ yLku Ãk]Úðe MkßÞkO. 2 Ãk]Úðe yMÃkÔÞMÃk yLku þqLÞ nÃke, yLku yøkkÄ s÷hkrþ WÃkh ytÄfkh AðkÞu÷ku nÃkku, yLku Ãkkýe Ãkh EïhLke þÂõÃk ½q{Ãke nÃke. 3 Eïhu fÃŒkwt, “«fkþ «økxku,†yLku «fkþ «økxâku.
I want to extract the text written after each , in the new rows i.e. a3,a4,a5,a6 and so on.
Please, help me I have around 200 such files containing similar data. Your guidance will help me a lot.
Thank you Sir.
-NelsonCM
Hello!
We have a ready-made solution for your task. I'd recommend you to have a look at our Ablebits Data Tool.
You can use the Convert Text function to replace the numbers with the # symbol. Then using the Split text - By Characters function, you can split the text into cells using the # separator.
It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.
If you have any other questions, please don’t hesitate to ask.
A1: FirstWord, B1: CharLen
A2: January, B2: 4
A5: SecondWord
A6: nuraminis
A7: literary
A8: arbitrary
A9: calendar
A10: hopeful
A11: sejanus
Looking for a formula in the B column that would return TRUE for any instance of the CharLen matched in the second word... So B6-B8,B11 = TRUE the the others would return FALSE.
Hello!
What is CharLen?
What matches did you find in the cells A6,A7,A8,A11?
Super helpful! thank you!!!!
Hello, i need help i have a phonetic checker file that will find the word in a cell that is inside this symbol (`), but unfortunately the formula that i created just can detect a one word, im planning to detect all the words inside the symbol in a cell
like for example `James`, had a little lamb. The lamb is `white` and `curly`.
My formula just detects the first word with (`) this symbol. I want it to be all of the words in a cell.
=IFERROR(MID(A1,FIND("‘",A1)+0,FIND("’",A1,FIND("‘",A1)+1)-FIND("‘",A1)+1),"") here is my formula.
Hello!
It is impossible to solve your problem with one formula. I recommend using the "`"separator and splitting your phrase into columns using the Split Text tool. It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.
After applying Split Text, you remove all even columns from the result and get the words you want.
Hello Alexander,
Looks like you have your work cut out for you.
I am sure you will be able to tell me the answer very quickly based on your experience.
I have a list of part numbers in Column A :
Column A
11234
11246
15363
12421
14642
I have a list of descriptions that may or may not contain the part numbers.
I want to verify if that part number exists in a non-organised list (meaning they are not in the corresponding cell they could be anywhere in the column.
If the part number exists within the description I want it to share it's adjacent cell which has a unique barcode.
Hopefully that helps if you need further information let me know.
Thanks,
Adam
Hello!
If I understand your task correctly, the following formula should work for you:
=IFERROR(INDEX($E$1:$E$10,MATCH(TRUE, ISNUMBER(SEARCH(A1,$D$1:$D$10,1)),0)),"")
$E$1:$E$10 - list of barcodes
$D$1:$D$10 - list of descriptions
I hope my advice will help you solve your task.
"Description: Document Source Type: Email
Record Locator: mary sherlene
name: xxxxxxxxxxxxx
Staging ID: 1111
Fax Number Requested: No"
Above data would be available on one cell, I want a formula to search for words " Record Locator: " and return name Mary sherlene
similarly, I want to do search or other information like apply formula to search for words "name:" and return me xxxxxxxxxxxxx as result. note. values are not constant like name will not be always xxxxx it can be yyyyy.
Hello!
Please try the following formula:
=MID(A1,SEARCH("Record Locator:",A1,1)+16, (SEARCH("name:",A1,1)) - (SEARCH("Record Locator",A1,1)+16)-1)
I hope my advice will help you solve your task.
Hi,
I would really appreciate if you can help me. I have a list of 150 popular words (A1: A150). I have a set of 500 customers' comments (B1: B500). I want to write a function that for each customer comment, excel searches for the occurrence of any of the 150 popular words (A1: A150) and returns the frequency of their occurrence in a cell in front of each customer.
For example, if I have 4 words (good, tasty, quite, fresh, like), and customer A said: "the meal was very tasty and fresh. I like the way food is presented. I also like the colours used in the place".
In this comment, tasty used 1 time; fresh used 1 time; like used twice.
I want the function to calculate the occurrence of these words as 4 times. I don't care about how many each word is repeated. I just need the total. I also want the function to be case insensitive since some customer might use capital case letters and other use lower case letters.
Many thanks
Hello!
Please try the following formula:
=SUM((LEN(A1)-LEN(SUBSTITUTE(A1,$D$1:$D$150,""))) / LEN($D$1:$D$150))
where
$D$1:$D$150 - list of 150 popular words
I hope it’ll be helpful.
Many thanks. It worked very well.
I also updated it to be case insensitive by
=SUM((LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),UPPER($D$1:$D$150),""))) / LEN($D$1:$D$150))
Thanks again. Much appreciated
Currently looking to extract text within an individual cell, using a list that contains characters in a list I created. The text in the list ranges from A0-Z10 as this is what is within all those cells that I am trying to extract. So for example Cell B2 reads "John Anderson H0468582 Dr. James Dean" This is just an example as the placing of the middle set of characters isn't always consistent. So i am trying to extract the H0468582 based off there being a "H0" in the list I created (which sits within a different tab of the excel sheet) in to cell H2 for example.
I'm not sure if I explained it very well but if you can help then that would be great
Hello!
Please try the following formula:
=LEFT(MID(A1,IF(SUM(IFERROR(SEARCH(G1:G10,A1,1),"")) > 0,SUM(IFERROR(SEARCH(G1:G10,A1,1),"")),""),100), SEARCH(" ",MID(A1,IF(SUM(IFERROR(SEARCH(G1:G10,A1,1),"")) > 0,SUM(IFERROR(SEARCH(G1:G10,A1,1),"")),""),100),1))
G1:G10 - list ranges, no blanks.
I hope it’ll be helpful.
Dear Madam, I am searching a words content , an example
Searching "100A TP 50KA EU" from sheet-1 to sheet-2 "100A TP ACB 50KA FIXED LSI FRANCE EU"
Please help me to get suitable formula.
Hi,
You haven't written what result you want to get. To determine that the text was found, you can use the following formula
=IF(IFERROR(SEARCH("*"&SUBSTITUTE(A1," ","*")&"*",B1,1),"")>0,"Yes","No")
A1 is “100A TP 50KA EU”.
I hope it’ll be helpful.
=LEFT(C3;SEARCH("/3/";C3)-1)
=LEFT(C3;SEARCH("/2/";C3)-1)
=LEFT(C3;SEARCH("/1/";C3)-1)
how to sum up these three search criteria in one formula and when this value is missing to return the text to the cell
Hello!
If I got you right, the formula below will help you with your task:
=CONCAT(IFERROR(LEFT(C3,SEARCH({"/1/","/2/","/3/"},C3)-1),""))
I hope I answered your question. If something is still unclear, please feel free to ask.
Hi
need help to match number from 2 different columns and the result is true if matching for example in one column i have 12345 and that is randomly placed in the other column, so if column A and Column B has 12345 the result should be true or else it should be false
I am trying to make a department shift schedule where I list the start times and fill in names, then transfer the information to a standard schedule. For example, if Sue's name is in the first 3 cells, then she is scheduled for 6:30A, if in the next 3 cells, then 7:00A, etc. What function will give me a value based on which cell her name is in?
Hello! I need help expanding on the concept of finding text between parenthesis. I have a cell with lots of lines of text between parenthesis and I want to find all the instances of words between parenthesis in this single cell, not just the first one. How do I get the formula =MID(P2,SEARCH("",P2)-SEARCH("<",P2)-1) to repeat for the second, third, fourth instances etc. of text between parenthesis?
Hi,
I want to extract the Invoice Number from the column of comments with different texts.
So, the first check is whether the cell has an Invoice number, If yes, then I need to extract the 4 digit number from the text string.
Please guide how I can do that.
Reverse - Standby Invoice 7286 posted twice
BNP Security - LND 11697 Receipt No 9613 - CHERRYBROOK for 13/9 - 31/10/19
BNP Security - LND 11697 Receipt No 9616 - NORWEST for 13/9 - 31/10/19
BNP Security - LND 11697 Receipt No 8252 - 129 Showground for Aug-19
Standby Invoice 7432 for Epping for May-20
Dear Sir ,
I have a list I need to do sorting based on 4 character or 5 digit from behind below are example.
appreciated if can help to sort or separate it will be easier rather than I do it manually
CB80W90D208 2
CB80W90P20 8
CBDEP0P16 2
CBDEP0P18 0
CBDEP2P18 223
CBDEP2P20 2
CBDGEAR100D208 0
CBDGEAR68D208 2
CBDST100D205 -9
CBDST100D208 8
CCOM100D205 4
Thanks
MilanoZalgiris
Real MadridFenerbahce
BarcelonaC.Zvezda
ValenciaMaccabi T.A.
NewcastleLondon Lions
Townsville (F)Bendigo (F)
Southside F. (F)Perth (F)
FlamengoCampo Mourao
PrometheusPAOK
Xarilaos T.AEK
Zielona GoraOstrow
Anwil W.A.Gdynia
Townsville (F)Bendigo (F)
Southside F. (F)Perth (F)
Sydney (F)Canberra (F)
WelsBC Vienna
Vienna DCA.Traiskirchen
OberwartKlosterneuburg
FlamengoCampo Mourao
Sao PauloFranca SP
MinasUnifacisa
BrasíliaPinheiros
KolinOstrava
ETHA E.Apop Paphos
Apoel N.E.N.Paralimni
OmoniaAEL Limassol
HermesAlkar
SkrljevoSibenik
ZabokZadar
HorsensHerlev W.
AmagerSvendborg
KobratKTP Basket
Helsinki S.UU-Korihait
Kaarinan U.B.Salon Vilpas
Mac.RishonB.Herzelia
L.RytasNeptunas
PrienaiPieno
FyllingenTromso
C.T.OsloNidaros J.
Asker AliensBaerums
EstudiantesUnicaja
Real BetisBilbao
ValenciaTenerife
ZaragozaBarcelona
Real MadridManresa
CantuVirtus Roma
PesaroR.Emilia
Fortitudo Bol.Virtus Bologna
TrentoVarese
BrindisiBrescia
MilanoVenezia
WurzburgHamburg
BayreuthMitteldeutscher
Alba BerlinBonn
Bayern M.Ludwigsburg
CrailsheimBamberg
IraklisPeristeri
LavriouIonikos N.
PanathinaikosKolossos
Dabrowa G.S.Wroclaw
StargardStarogard G.
BrasíliaPinheiros
Hi. Can anyone help me with a formula or vba to split these strings by the continuous middle continuous substing it contains? eg. Dabrowa G.S.Wroclaw in Dabrowa G.S. - Wroclaw. THX