To extract the first, middle and last name we use the formulas «LEFT», «RIGHT», «MID», «LEN», and «SEARCH» in Excel.
LEFT: Returns the first character(s) in a text string based on the number of characters specified.
Syntax of «LEFT» function: =LEFT (text,[num_chars])
Example:Cell A2 contains the text «Mahesh Kumar Gupta»
=LEFT (A2, 6), function will return «Mahesh»
RIGHT:Return the last character(s) in a text string based on the number of characters specified.
Syntax of «RIGHT» function: =RIGHT (text, [num_chars])
Example:Cell A2 contains the text «Mahesh Kumar Gupta»
=RIGHT (A2, 5), function will return «GUPTA»
MID:Return a specific number of character(s) from a text string, starting at the position specified based on the number of characters specified.
Syntax of «MID» function: =MID (text,start_num,num_chars)
Example:Cell A2 contains the text «Mahesh Kumar Gupta»
=MID (A2, 8, 5), function will return «KUMAR»
LEN:Returns the number of characters in a text string.
Syntax of «LEN» function: =LEN (text)
Example:Cell A2 contains the text «Mahesh Kumar Gupta»
=LEN (A2), function will return 18
SEARCH:The SEARCH function returns the starting position of a text string which it locates from within the text string.
Syntax of «SEARCH» function: =SEARCH (find_text,within_text,[start_num])
Example:Cell A2 contains the text «Mahesh Kumar Gupta»
=SEARCH («Kumar», A2, 1), function will return 8
How to separating the names in Excel through formula?
To understand how you can extract the first, middle and last name from the text follow the below mentioned steps:
Example 1: We have a list of Names in Column “A” and we need to pick the First name from the list. We will write the «LEFT» function along with the «SEARCH» function.
- Select the Cell B2, write the formula =LEFT (A2, SEARCH (» «, A2)), function will return the first name from the cell A2.
- To Copy the formula in all cells press the key “CTRL + C” and select the cell B3 to B6 and press the key “CTRL + V” on your keyboard.
To pick the Middle name from the list. We write the “MID” function along with the “SEARCH” function.
- Select the Cell C2, write the formula =MID(A2,SEARCH(» «,A2,1)+1,SEARCH(» «,A2,SEARCH(» «,A2,1)+1)-SEARCH(» «,A2,1)) it will return the middle name from the cell A2.
- To Copy the formula in all cells press key “CTRL + C” and select the cell C3 to C6 and press key “CTRL + V”on your keyboard.
To pick the Last name from the list. We we will use the “RIGHT” function along with the “SEARCH” and “LEN” function.
- Select the Cell D2, write the formula =RIGHT(A2,LEN(A2)-SEARCH(» «,A2,SEARCH(» «,A2,SEARCH(» «,A2)+1))) It will return the last name from the cell A2.
- To Copy the formula in all cells press key “CTRL + C” and select the cell D3 to D6 and press key “CTRL + V” on your keyboard.
This is the way we can split names through formula in Microsoft Excel.
To know more find the below examples:-
Extract file name from a path
How to split a full address into 3 or more separate columns
When working with the names dataset in Excel, often there is a need to slice and dice the dataset and extract a part of it.
One common task many Excel users have to do is to extract the last name from the full name.
While it may seem like an easy task, it can get complicated (especially when you’re dealing with data that is not consistent).
In this tutorial, I will show you five different ways to extract the last name from the full name in Excel. I will cover different scenarios, where you only have the first and the last name in the dataset, or the first, middle, and last name.
So let’s get started!
Extract Last Name Using Find and Replace
Extracting the last name from a full name essentially means you’re replacing everything before the last name with a blank.
And this can easily be done using Find and Replace in Excel (and it takes less than 3 seconds).
Below I have a names data set from which I want to extract only the last name.
Below are the steps to use Find and Replace to remove everything before the last name:
- Copy the name data from Column A and paste it in Column B. I am doing this to keep the original data intact. If you only need the last name, you can skip this step.
- Select all the names in column B
- Hold the Control key and press the H key (Command + H if using Mac). This will open the Find and Replace dialog box.
- In the Find and Replace dialog box, enter the following in the Find what field: * (an asterisk symbol followed by a space character)
- Leave the Replace with field empty/blank
- Click on Replace All
The above steps food remove anything before the last space character, which would leave us with the last names only.
The above method would also work in case you have an inconsistent names dataset. For example, if you have names that may or may not have a middle name/initial, or may have a prefix such as Mr or Ms. The only condition is that the last name should be at the end of the name
How does this work?
In the ‘Find what’ field in the Find and Replace dialog box, I have used an asterisk sign (*) followed by a space character.
Asterisk is a wild card character that represents any number of characters in Excel.
So when I ask it to find an asterisk followed by the space character, it will find the last space character in the cell and everything before that space character would be considered a part of the asterisk.
And when I replace it with a blank, everything before the last space character is removed.
Note: For this method to work you need to make sure that there are no trailing spaces in your data. In case there is a space character after the last name, doing the above Find and Replace operation would remove everything from the cell. To make sure there are no trailing spaces, you can use the TRIM formula (read – how to remove trailing spaces in Excel)
Extract Last Name Using Formulas (When you Have Only First and Last name)
Suppose you have a data set as shown below where you have the first name and the last name in column A, and you only want to extract the last name from it.
Below is the formula that will do that:
=RIGHT(A2,LEN(TRIM(A2))-FIND(" ",TRIM(A2)))
Let me quickly explain how this formula works.
The above formula uses the FIND function to get the position of the space character in the name.
Since the position of the space character would be between the first and the last name, once we have the position of the space character, we can use that to extract everything to the right of it (which would be the last name)
But how many characters from the right should it extract?
Since we have the position of the space character, we can subtract that value from the length of the name (which is given by the LEN function). This tells us how many characters are there after the space character in the name.
And this value is then used in the RIGHT formula to extract the last name from the full name.
Note that I have used TRIM(A2) instead of A2 in this formula. This is because there is a possibility that the cells containing the names may have leading, trailing, or double spaces in them. Using the TRIM function makes sure that all these extra spaces are ignored and only one space character between the first name and the last name is considered.
Extract Last Name Using Formulas (When you Have First, Middle, and Last name)
In case you have the first, middle, and last name, the formula becomes a little bit longer.
Below I have a data set where I have the first, middle, last name in column A, and I want to extract the last name from it.
Here is a formula that can do that:
=RIGHT(TRIM(A2),LEN(TRIM(A2))-SEARCH(" ",TRIM(A2),SEARCH(" ",TRIM(A2))+1))
The above function uses the same concept where we have to find out the position of the last space character, and then extract everything to the right of that space character.
But since there are two space characters, in this case, the challenge is to find out the position of this second space character.
To do this, I have used the below-nested SEARCH function (i.e., Search function within a search function)
=SEARCH(" ",TRIM(A2),SEARCH(" ",TRIM(A2))+1)
This part of the formula gives us the position of the second space character, which is then used within the RIGHT formula to extract the last name.
Note that this formula would only work when you have a consistent names dataset – i.e., all the names have the first, middle, and last names.
In case you have a mix of names where some may have middle names but some may not, this formula is not going to work.
If that is the case, use the formula in the next section.
When You Have Incosistent Data (Names with and Without Middle Name)
Below I have a named data set where the format is not consistent – in some cells, we only have the first and last name, and in some cells, there are a middle name and/or prefixes as well.
While you can still use excel formulas to extract the last name in this case, the formula we’ll get a little bit complicated.
Below is the formula that will extract the last name in this inconsistent data set:
=RIGHT(SUBSTITUTE(A2," ","|",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))),LEN(SUBSTITUTE(A2," ","|",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))-FIND("|",SUBSTITUTE(A2," ","|",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))
Also read: How to Switch First and Last Name in Excel with Comma?
Extract Last Name using Flash Fill
Another really fast way to extract the last name from full names is by using the Flash Fill feature in Excel.
Introduced in Excel 2013, Flash Fill works by identifying patterns based on user input and giving you the same results for all the cells in the column.
Below I have a data set where I have the names in column A and I want to extract the last name in column B.
Here are the steps to do this Flash Fill:
- In cell B2, manually enter the last name from the name in cell A2
- Select the range in column B where you want the last names (B2:B10 in this example)
- Hold the Control key and press the E key (or Command + E if using Mac)
Note: You can also get the same option when you go to the Home tab, click on the Fill icon, and then click on Flash Fill
The above steps would fill the selected range with the last names from names in Column A.
As I mentioned, Flash Fill works by identifying the pattern in one or two cells where you have manually entered the data and then replicates it for all the other select cells.
In this example, when I entered “Hans” in cell B2, and then used Flash Fill, it recognized that I’m trying to extract the last word from the text string in column A. So we did the same for all the cells I selected.
In case you have a dataset where you have a mix of names with and without a middle name, you can still use Flash Fill to extract the last name.
This is because the pattern that the flash fill has identified is to extract the last word from the text string, so it doesn’t matter how many words are there, it will give you the last name in any case.
Caution: While the flash fill method has worked perfectly in our case, its accuracy is dependent on how well it can identify the pattern. In some cases, it may not be able to identify the right pattern, so it’s important that you double-check the data to make sure it’s correct. In some cases, you may need to enter the data in two or three cells for flash fill to identify the pattern correctly
Compared with the formula method covered above, the flash fill method is a lot faster and more convenient.
One big difference however is that the result of the formula method is dynamic, which means that in case you change the original name, the result in the cell that has the formula would also update.
In the case of Flash Fill, you will have to repeat the same process again to get the updated data
Extract Last Name Using Power Query
If you want to automate the process of extracting the last names from full names, Power Query is the way to go.
For example, if you often have a need to separate names in Excel or to extract the first or last name, you can do that once using Power Query, and the next time you need to do it again, you can simply refresh the query with a single click.
Below I have a data set of names and I want to extract the last name from these. Note that I have a mix of names where there are middle names and prefixes in some of the cells.
Note: When using Power Query, it is best to convert your data into an Excel Table. Doing this would make it a lot easier to work with Power Query, and also allow you to perform the same steps with a single click the next time you add new data set.
To convert your data into an Excel Table, select the data and use the keyboard shortcut Control + T (or Command + T if using Mac)
Below are the steps to use Power Query to get the last name from this dataset:
- Select any cell in the dataset
- Click the Data tab in the ribbon
- In the ‘Get and Transform Data’ group, click on ‘From Selection’. This will open the Power Query editor
- In the PQ Editor, right-click on the column header
- Go to the ‘Split Column’ option
- Click on By Delimiter option.
- In the ‘Split Column by Delimiter’ dilaog box, select Space as the delimiter (if not selected already)
- In the Split at options, select ‘Right-most delimiter’
- Click OK. This will close the dialog box and you will see the result in the PQ Editor
- Rename the columns the way you want (I am going with ‘Full Name’ and ‘Last Name’)
- Click on Close and Load option in the ribbon
The above steps would insert a new worksheet in your workbook that would have the resulting table.
Note that in the above example, the first name column has the first name as well as the middle name in some cases. In case you only want the last names, you can delete the first column in Power Query, so it will only give you the last name column as the result in the worksheet.
Now if you’re thinking that this is a long method and you’re better off using Flash Fill or formula method instead, you’re probably right.
The scenario where Power Query really shines is when you get a file that has the data and you need to do multiple modifications to it (say delete some columns, delete blank rows, extract the last name, etc).
The next time you get a new file, you won’t have to repeat all these steps again. simply connect your query to the new file and refresh the query.
In such scenarios, Power Query is a far better solution than using flash fill or formulas or even VBA.
So these are three different methods that you can use to extract the last name from full name in Excel. Personally, I prefer using the Flash Fill method in most cases, as it’s fast and quite reliable.
I hope you found this tutorial useful!
Other Excel tutorials you may also like:
- How to Shuffle a List of Items/Names in Excel?
- How to Combine First and Last Name in Excel)
- How to Sort by the Last Name in Excel
- Extract Usernames from Email Ids in Excel
- Separate First and Last Name in Excel (Split Names Using Formulas)
- How to Extract the First Word from a Text String in Excel
Summary
This step-by-step article describes how to find data in a table (or range of cells) by using various built-in functions in Microsoft Excel. You can use different formulas to get the same result.
Create the Sample Worksheet
This article uses a sample worksheet to illustrate Excel built-in functions. Consider the example of referencing a name from column A and returning the age of that person from column C. To create this worksheet, enter the following data into a blank Excel worksheet.
You will type the value that you want to find into cell E2. You can type the formula in any blank cell in the same worksheet.
A |
B |
C |
D |
E |
||
1 |
Name |
Dept |
Age |
Find Value |
||
2 |
Henry |
501 |
28 |
Mary |
||
3 |
Stan |
201 |
19 |
|||
4 |
Mary |
101 |
22 |
|||
5 |
Larry |
301 |
29 |
Term Definitions
This article uses the following terms to describe the Excel built-in functions:
Term |
Definition |
Example |
Table Array |
The whole lookup table |
A2:C5 |
Lookup_Value |
The value to be found in the first column of Table_Array. |
E2 |
Lookup_Array |
The range of cells that contains possible lookup values. |
A2:A5 |
Col_Index_Num |
The column number in Table_Array the matching value should be returned for. |
3 (third column in Table_Array) |
Result_Array |
A range that contains only one row or column. It must be the same size as Lookup_Array or Lookup_Vector. |
C2:C5 |
Range_Lookup |
A logical value (TRUE or FALSE). If TRUE or omitted, an approximate match is returned. If FALSE, it will look for an exact match. |
FALSE |
Top_cell |
This is the reference from which you want to base the offset. Top_Cell must refer to a cell or range of adjacent cells. Otherwise, OFFSET returns the #VALUE! error value. |
|
Offset_Col |
This is the number of columns, to the left or right, that you want the upper-left cell of the result to refer to. For example, «5» as the Offset_Col argument specifies that the upper-left cell in the reference is five columns to the right of reference. Offset_Col can be positive (which means to the right of the starting reference) or negative (which means to the left of the starting reference). |
Functions
LOOKUP()
The LOOKUP function finds a value in a single row or column and matches it with a value in the same position in a different row or column.
The following is an example of LOOKUP formula syntax:
=LOOKUP(Lookup_Value,Lookup_Vector,Result_Vector)
The following formula finds Mary’s age in the sample worksheet:
=LOOKUP(E2,A2:A5,C2:C5)
The formula uses the value «Mary» in cell E2 and finds «Mary» in the lookup vector (column A). The formula then matches the value in the same row in the result vector (column C). Because «Mary» is in row 4, LOOKUP returns the value from row 4 in column C (22).
NOTE: The LOOKUP function requires that the table be sorted.
For more information about the LOOKUP function, click the following article number to view the article in the Microsoft Knowledge Base:
How to use the LOOKUP function in Excel
VLOOKUP()
The VLOOKUP or Vertical Lookup function is used when data is listed in columns. This function searches for a value in the left-most column and matches it with data in a specified column in the same row. You can use VLOOKUP to find data in a sorted or unsorted table. The following example uses a table with unsorted data.
The following is an example of VLOOKUP formula syntax:
=VLOOKUP(Lookup_Value,Table_Array,Col_Index_Num,Range_Lookup)
The following formula finds Mary’s age in the sample worksheet:
=VLOOKUP(E2,A2:C5,3,FALSE)
The formula uses the value «Mary» in cell E2 and finds «Mary» in the left-most column (column A). The formula then matches the value in the same row in Column_Index. This example uses «3» as the Column_Index (column C). Because «Mary» is in row 4, VLOOKUP returns the value from row 4 in column C (22).
For more information about the VLOOKUP function, click the following article number to view the article in the Microsoft Knowledge Base:
How to Use VLOOKUP or HLOOKUP to find an exact match
INDEX() and MATCH()
You can use the INDEX and MATCH functions together to get the same results as using LOOKUP or VLOOKUP.
The following is an example of the syntax that combines INDEX and MATCH to produce the same results as LOOKUP and VLOOKUP in the previous examples:
=INDEX(Table_Array,MATCH(Lookup_Value,Lookup_Array,0),Col_Index_Num)
The following formula finds Mary’s age in the sample worksheet:
=INDEX(A2:C5,MATCH(E2,A2:A5,0),3)
The formula uses the value «Mary» in cell E2 and finds «Mary» in column A. It then matches the value in the same row in column C. Because «Mary» is in row 4, the formula returns the value from row 4 in column C (22).
NOTE: If none of the cells in Lookup_Array match Lookup_Value («Mary»), this formula will return #N/A.
For more information about the INDEX function, click the following article number to view the article in the Microsoft Knowledge Base:
How to use the INDEX function to find data in a table
OFFSET() and MATCH()
You can use the OFFSET and MATCH functions together to produce the same results as the functions in the previous example.
The following is an example of syntax that combines OFFSET and MATCH to produce the same results as LOOKUP and VLOOKUP:
=OFFSET(top_cell,MATCH(Lookup_Value,Lookup_Array,0),Offset_Col)
This formula finds Mary’s age in the sample worksheet:
=OFFSET(A1,MATCH(E2,A2:A5,0),2)
The formula uses the value «Mary» in cell E2 and finds «Mary» in column A. The formula then matches the value in the same row but two columns to the right (column C). Because «Mary» is in column A, the formula returns the value in row 4 in column C (22).
For more information about the OFFSET function, click the following article number to view the article in the Microsoft Knowledge Base:
How to use the OFFSET function
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
There were countless times when I had a list of full names, and all I needed was the First Name. It would be time-consuming to get the first names one by one.
Thank goodness there are formulas for Excel extract the first name from full name to make my life easier!
In this article, you will be provided with a detailed guide on how to extract first name in Excel:
- Using Find & Left formula
- Using Text to Column feature
Let’s explore each of these methods to extract first name from full name in Excel one-by-one.
Using Find and Left formula
It’s very easy to do Excel extract first name with the LEFT and FIND formula!
Here is the gameplan:
- Use the FIND formula to find the location of the space or any other delimiter that separates the First Name and the Last Name
- However, we need to deduct this numerical location by 1, so that we have the location of the end of the First Name
- With this number, we will use the LEFT formula to retrieve the First Name!
Now, it is essential to understand how these functions work to be able to use them to Excel extract first name.
The FIND Formula is used to find the position of the specified text within a cell.
The syntax of FIND formula is:
=FIND(find_text, within_text, [start_num])
- find_text: It is the text you want to find. Here, we want to find space. So, the argument will be a blank within quotes.
- within_text: It is the cell containing the text you want to find.
- start_num: It specifies the character at which you want the search to start. This is an optimal argument. If left blank, Excel will start the search from the 1st character itself.
The LEFT Formula is used to extract the specified number of characters from the start of a text string.
The syntax of the TEXT formula is:
=LEFT(text, num_chars)
- text: It is the text string from which you want to extract characters
- num_chars: It is the number of characters you want to extract.
Moving on, let’s combine these two formulas to Excel extract first name from full names.
Watch it on YouTube and give it a thumbs-up!
Follow the step-by-step tutorial below on how to get first name in Excel and make sure to download the Excel workbook to follow along:
DOWNLOAD EXCEL WORKBOOK
STEP 1: We need to enter the LEFT function and select the Full Name:
=LEFT(C7
STEP 2: We need to enter the FIND formula to get the empty space located between the first and last name:
=LEFT(C7, FIND(” “
STEP 3: Select the Full Name again for the FIND formula’s 2nd argument:
=LEFT(C7, FIND(” “, C7)
STEP 4: Deduct 1 from the FIND formula so that our result will return us the text up to the last letter of the first name:
=LEFT(C7, FIND(” “, C7) -1)
STEP 5: Do the same for the rest of the cells by dragging the formula all the way down using the left mouse button.
Now you are able to extract all the First Names from your FULL NAME using the FIND & LEFT formula in Excel!
Using Text to Column feature
A quick and easier way to Excel extract first name is to use the Text to Column function!
All you need to know is first the delimiter between the first and last name. Here, the first and last name is separated by a COMMA (,).
This function will get the first and last names split into two separate columns. Get this done by following the steps below:
STEP 1: Select the cells containing the full names.
STEP 2: Go to Data > Text to Column.
STEP 3: In the Convert Text to Columns wizard, Select Delimited Option and Click Next.
A snapshot of your selected data is displayed at the bottom of the wizard.
STEP 4: Select one or more delimiter applicable for your data and Click Next. Here, we need to select the delimiter – comma.
If your data contained both comma and space as a separator, you can select both!
STEP 5: In this step, you can select the location where you want the output to be displayed. Click on the small arrow next to the destination to insert your destination.
STEP 6: Select cell D7 and click on the arrow again.
STEP 7: Click Finish.
And, it’s done! The first and last names are now separated and displayed in two separate columns.
About The Author
Bryan
Bryan is a best-selling book author of the 101 Excel Series paperback books.
This post will guide you how to use Excel FIND function with syntax and examples in Microsoft excel.
Table of Contents
- Description
- Syntax
- Excel Find Function Examples
- Frequently Asked Questions
- Related Functions
- More FIND Formula Examples in Excel
Description
The Excel FIND function returns the position of the first text string (sub string) within another text string.
It can be used when you want to get the position of a sub string inside another text string. so it will return a number that indicates the starting position of sub string that you are searching in another text string.
The FIND function is a build-in function in Microsoft Excel and it is categorized as a Text Function.
Note: The FIND Function is case-sensitive.
The FIND function is available in Excel 2016, Excel 2013, Excel 2010, Excel 2007, Excel 2003, Excel xp, Excel 2000, Excel 2011 for Mac.
Syntax
The syntax of the FIND function is as below:
= FIND(find_text, within_text,[start_num])
Where the FIND function arguments are:
- Find_text -This is a required argument. The text or substring that you want to find. (The string in the Find_text argument can not contain any wildcard characters)
- within_text -This is a required argument. The text string that is to be searched
- start_num-This is an optional argument. It will specify the position in within text string where the search will start. If you omit start_num value, the search will start from the first character of the within_text string, in other words, it is set to be 1 by default. So you can use the Excel Find function to look for the specified text starting from the specified position.
Note:
- The Find function will return the position of the first character of find_text in within_text argument.
- If there are several occurrences of the find_text within another text string, it only return the position of the first occurrence.
- If the find_text is an empty string, the position of the first character in the within_text is returned.
- If the find_text string is not found in within_text, it will return the Excel #VALUE! Error.
- If start_number value is not greater than 0, it will return the #VALUE! Error value.
- As the FIND function is case-sensitive. If you want to do a search that is case-insensitive , you can use the SEARCH Function.
- The FIND function does not support wildcard characters, so if you want to use wildcard characters to find string, you can use SEARCH function in excel.
Excel Find Function Examples
The below example will show you how to use Excel FIND Text function to find the position of a sub string within text string.
#1 To get the position of sub string “how” in cell B1, just using formula:
=FIND("how",B1,1).
When you look for the text “how” in the Cell B1, it will return 6, which is the position of the first character of find_text “how” within the Cell B1.
#2 To get the position of sub string “how”in cell b1, starting with the third character, using formula:
=FIND("how",B1,3)
In the above example, it specified the start_num value as “3“, so you will get the position of the first character “h” of the searched string “how” within the value in Cell B1 when the starting position is 3. it returns 6.
The Example 1The search will start from the third character of the value in Cell B1.
#3 Finding “excel” string in Cell B1, using the following Find formula:
=FIND("excel",B1,1) =FIND("excel",B1,3)
when you set the starting position as 1, it will return the position of the first “excel” string in the value of Cell B1.
When you set the starting position as 3, it will return the position of the second “excel” string in the value of Cell B1. The search will start from the third character of the value in Cell B1.
#4 Searching an empty string in Cell B1, using the following Find formula:
=FIND("",B1,1)
In the above example, when you look for an empty string in Cell B1 with the starting position as 1, and it will return the position of the first character of the within_ text (the value of Cell B1).
#5 Searching “word” text in Cell B1, using the following Find formula:
=FIND("word", B1,1)
In the above example, when you look for the text “word” in Cell B1 and the string position is 1, it will return a #VALUE! error, As the searched string “word” is not found in Cell B1.
#6 Searching for a text as “excel” in Cell B1 and the starting position is a negative number.
=FIND("excel",B1,-1)
If the starting position is not greater than 0, it will return a #VALUE! Error.
#7 Searching for a string as “EXCEL” in Cell B1, using the following formula:
=FIND("EXCEL",B1,1)
As the FIND function in excel is case-sensitive, when you look for the string “EXCEL” in Cell B1, the searched string “EXCEL” is not found, the function will return a #VALUE! error.
Frequently Asked Questions
Question 1: the FIND function returns a #VALUE error when it do not find the searched text within another string. I want to know if there is another excel function in combination with the find function to handle the error message to return the actual value, such as: -1 or throwing others exceptions via returning values, like: -1,0 or FALSE.
Answer: As mentioned above, the FIND function is case-sensitive, and it can be combined with the ISNUMBER function and IF function to create a new IF excel formula as follows:
=IF(ISNUMBER( FIND("excel",B1)), FIND("excel",B1), "not found")
The FIND function will locate the position of the searched text “excel” within Cell B1, and the ISNUMBER function will check the result returned by the FIND function if it is a number, if TRUE, then return TRUE, otherwise , returns FALSE. then the IF will check the Boolean value returned by ISNUMBER function, If TRUE, then returns the numeric position returned by the second FIND function, If FALSE, returns “not found” string.
If you want a case-insensitive match and you can use the SEARCH function instead of the FIND function in the above formula:
=IF(ISNUMBER( SEARCH("excel",B1)), SEARCH("excel",B1), "not found")
Question 2: I want to extract a sub string from a string that separated by wildcard characters. I tried to use the below FIND formula to handle it. but it returned a #VALUE error message. Could you please help to check the below formula I used:
=RIGHT(B1,FIND("~**",B1))
Answer: you can use the following formula:
=TRIM(RIGHT(B1,Len(B1) - FIND("**",B1)-1))
The find function will return the position of the first wildcard (**) character within a string in Cell B1. you need subtract the numeric position returned by FIND function from the length of the string in Cell B1 to get the length of sub string to the right of the wildcard character(asterisk). then the RIGHT function extracts the rightmost characters based on the length of sub string.
or you can use another formula to achieve the same result as follows:
=MID(B1,FIND("**",B1)+2,255)
Question 3: I am trying to extract the first word from another text string separated by space character. but it always return a #VALUE error message. I think it should be use the FIND function in combination with another function, such as: left function. but I still don’t know how to combine with those two functions to extract the first word.
Answer: right, you can create a excel formula that uses the FIND function and LEFT function. and you can use the below formula:
=IFERROR(LEFT(B1, FIND(" ",B1)-1),B1)
The find function returns the position of the first space character in the text string in Cell B1. the Formula “=FIND(” “,B1)-1 returns the numbers of the first word as the second arguments of the LEFT function.
If the text string in Cell B1 just only contains one word, then the find function will return #VALUE error. to handle this error, you need to use the IFERROR function, if the find function is not find the space character, then return the text string in B1. in other words, it just contains only one word in Cell B1.
Question 4: I am trying to extract an email address from a text string in Cell B1. how to write a excel formula to achieve the result.
Answer: you can use a combination of the TRIM function, the LEFT function, the SUBSTITUTE function, the MID function, the MAX function and the REPT function to create a complex excel formula to extract email address from a string in Cell B1.
=TRIM(RIGHT(SUBSTITUTE(LEFT(B1,FIND (" ",B1&" ",FIND("@",B1))-1)," ", REPT(" ",LEN(B1))),LEN(B1)))
=TRIM( MID( SUBSTITUTE(B1, " ", REPT(" ",255)), MAX(1, FIND( "@", SUBSTITUTE(B1, " ", REPT(" ",255))) -50),255))
Question 5: I am trying to get the first name from a full name separated by a comma character. how to use a excel formula to extract the first name from a name as: “Last name, First name” format.
Answer: you can use a combination with the RIGHT function, the LEN function and the FIND function to create a excel formula to get the first name from a name. just using the following formula:
=RIGHT(B1,LEN(B1) - FIND(", ",B1)-1)
- Excel SEARCH function
The Excel SEARCH function returns the number of the starting location of a substring in a text string.The syntax of the SEARCH function is as below:= SEARCH (find_text, within_text,[start_num])… - Excel Find function
The Excel FIND function returns the position of the first text string (substring) from the first character of the second text string.The FIND function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the FIND function is as below:= FIND (find_text, within_text,[start_num])… - Excel ISERROR function
The Excel ISERROR function returns TRUE if the value is any error value except #N/A. The ISERROR function is a build-in function in Microsoft Excel and it is categorized as an Information Function. The syntax of the ISERROR function is as below: = ISERROR (value) … - Excel ISNUMBER function
The Excel ISNUMBER function returns TRUE if the value in a cell is a numeric value, otherwise it will return FALSE.The syntax of the ISNUMBER function is as below:= ISNUMBER (value)… - Excel RIGHT function
The Excel RIGHT function returns a sub string (a specified number of the characters) from a text string, starting from the rightmost character.The syntax of the RIGHT function is as below:= RIGHT (text,[num_chars])… - Excel LEN function
The Excel LEN function returns the length of a text string (the number of characters in a text string).The LEN function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the LEN function is as below:= LEN(text)… - Excel MID function
The Excel MID function returns a sub string from a text string at the position that you specify. The MID function is a build-in function in Microsoft Excel and it is categorized as a Text Function. The syntax of the MID function is as below: = MID (text, start_num, num_chars) … - Excel SUBSTITUTE function
The Excel SUBSTITUTE function replaces a new text string for an old text string in a text string.The syntax of the SUBSTITUTE function is as below:= SUBSTITUTE (text, old_text, new_text,[instance_num])… - Excel LEFT function
The Excel LEFT function returns a sub string (a specified number of the characters) from a text string, starting from the leftmost character.The LEFT function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the LEFT function is as below:= LEFT(text,[num_chars])… - Excel REPT function
The Excel REPT function repeats a text string a specified number of times.The REPT function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the REPT function is as below:= REPT (text, number_times)…
More FIND Formula Examples in Excel
-
Split Text String by Specified Character
you should use the Left function in combination with FIND function to split the text string in excel. And we can refer to the below formula that will find the position of “-“in Cell B1 and extract all the characters to the left of the dash character “-“.=LEFT(B1,FIND(“-“,B1,1)-1).… - Split Text String by Line Break
When you want to split text string by line break in excel, you should use a combination of the LEFT, RIGHT, CHAR, LEN and FIND functions. The CHAR (10) function will return the line break character, the FIND function will use the returned value of the CHAR function as the first argument to locate the position of the line break character within the cell B1.… - Split Text and Numbers in Excel
If you want to split text and numbers, you can run the following excel formula that use the MIN function, FIND function and the LEN function within the LEFT function in excel. .… - Get the Current Worksheet Name only
If you want to get the current worksheet name only in excel, you can use a combination of the MID function, the CELL function and FIND function.… - Get full File Name (workbook and worksheet) and Path
In excel, you can get the current workbook name and it is absolute path using the CELL function. Just refer to the following formula:=CELL(“filename”,B1).… - Get the Current Workbook Name
If you want to get the name of the current workbook only, you can use a combination of the MID function, the CELL function and the FIND Function… - Get Path and Workbook name only
If you want to get the workbook name and its path only without worksheet name, you can use a combination of the SUBSTITUTE function, the LEFT function, the CELL function and the FIND function…. - Get First Name From Full Name
If you want to get the first name from a full name list in Column B, you can use the FIND function within LEFT function in excel. The generic formula is as follows:=LEFT(B1,FIND(” “,B1)-1).… - Get Last Name From Full Name
To extract the last name within a Full name in excel. You need to use a combination of the RIGHT function, the LEN function, the FIND function and the SUBSTITUTE function to create a complex formula in excel..… - The different between FIND and SEARCH functions
There are two big differences between FIND and SEARCH functions in excel.The FIND function is case-sensitive. And the SEARCH function is case-insensitive…… - Data Validation for Specified Text only
If you want to check if the values that contain a specified text string in one cell, you can use a combination of the FIND function and ISNUMBER function as a formula in the Data Validation….… - Count Cells That Contain Specific Text
This post will discuss that how to count the number of cells that contain specific text or certain text in a specified cells of range in Excel. How to get the total number of cells that contain certain text.…… - Split Text and Numbers
If you want to split text and numbers from one cell into two different cells, you can use a formula based on the FIND function, the LEFT function or the RIGHT function and the MIN function. .… - Quickly Get Sheet Name
If you want to quickly get current worksheet name only, then inert it into one cell. You can use a formula based on the MID function in combination with the FIND function and the Cell function…… - Sorting IP Address
Assuming that you have an IP list of data in the range of cells B1:B5, and you want to sort those IP list from low to high, how to achieve the result with excel formula. You need to create a formula based on the Text Function, the LEFT function, the FIND function and the MID function, the RIGHT function..… - Removing Salutation from Name
To remove salutation from names string in excel, you can create a formula based on the RIGHT function, the LEN function and the FIND function…… - List all Worksheet Names
Assuming that you have a workbook that has hundreds of worksheets and you want to get a list of all the worksheet names in the current workbook. And the below will introduce 3 methods with you..… - Insert The File Path and Filename into Cell
If you want to insert a file path and filename into a cell in your current worksheet, you can use the CELL function to create a formual……..
Excel allows us to get first name from name using the FIND and LEFT functions. This step by step tutorial will assist all levels of Excel users in getting first name from name
Figure 1. The final result of the formula
Syntax of the FIND Formula
The generic formula for the FIND function is:
=FIND(find_text, within_text)
The parameters of the FIND function are:
- find_text – a text that we want to find in selected text or cell
- within_text – a text or cell where we want to find a text.
If a text is found, the FIND function returns a position of text in a cell. If it’s not found, the function returns #VALUE! error.
Syntax of the LEFT Formula
The generic formula for the LEFT function is:
=LEFT(text, [num_chars])
The parameters of the LEFT function are:
- text – a text from which we want to get a first part
- [num_chars] – a number of characters that we want to get from a text from the left side. This is the optional parameter, but if it is omitted, the function will return the text itself.
Setting up Our Data for the Example
Our table consists of w columns: “Full Name” (column B) and “First Name” (column C). In column C, we want to get the first name from a full name.
Figure 2. Data that we will use in the examples
Get the First Name from the Name
In the example, we want to get the first name in the cell C3, from the full name in B3. We will first find a space and get all characters before the space.
The formula looks like:
=LEFT(B3, FIND(" ", B3)-1)
The find_text parameter of the FIND function is the space (“ “) and within_text is B3. The result of this function is the position of the space in B3. This value minus 1 is the num_chars parameter of the LEFT function, while B3 is the text parameter.
To apply the formula we need to follow these steps:
- Select cell C3 and click on it
- Insert the formula:
=LEFT(B3, FIND(" ", B3)-1)
- Press enter
- Drag the formula down to the other cells in the column by clicking and dragging the little “+” icon at the bottom-right of the cell.
Figure 3. Using the formula to get the first name from the full name
The FIND function returns 5 as the position of the space in B3. Therefore the LEFT function returns 4 characters from B3. The result in the cell C3 is “Mike”.
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.
-
Check Also Extract Substring Between Parenthesis In Excel
-
Check Also Count Number Of Users Who Are Active In An Excel Workbook
-
Check Also VBA To Open Latest Excel Workbook
-
Check Also Print Cell Height And Cell Width Of A Cell In Excel
-
Check Also Delete Non Numeric Values From Numeric Field In Excel
-
Check Also Create Rows From Column In Excel
-
Check Also Sum Numbers Separated By Symbol In Excel
-
Check Also Sort Comma Separated Values Within A Cell In Excel
In this pose we will see how to extract first name and initial of last name in excel given the full name.
Suppose we have been given full name in column A which consists of first name and last name separated by space and we are required to extract the first name and only the initial of the last name.
In the pic below, you could see in column A we have names and in column B is the output that we want i.e. just first name and the first character of last name.
We will use a combination of LEFT and FIND function in excel to extract first name and the first character of name as shown above.
LEFT(text, length) function extracts the string from text starting from the first position to the number of characters denoted by length.
FIND(text, character,starting_pos) function finds the position of any particular character that we provide in the second argument, the third argument starting_pos is optional which lets you decide from where the excel should start searching the character.
We will try to build a formula to get the first name along with the initial of last name by applying these formulae.
Enter the formula =LEFT(A2,FIND(” “,A2)+1) in cell B2 as shown in the pic below.
As you could see we are extracting the string till one position further where we encounter a space in the full name.
So FIND(” “,A2) is giving us the position of the space and +1 in the formula is because I want to extract the first character from the last name, if I were to extract first 3 characters from the last name I would give +3 in the formula.
You could see below in the screen shot that we have got the output with first name and an the initial of last name.
So our LEFT function is extracting the first name and the first character of the last name with the help of FIND function in excel.
Now drag the formula till row 6 as shown below.
Hope this helped.
Random Posts