top of page

How to Extract Everything to The Left of a Specific Character in Excel


How to Extract Everything to The Left of a Specific Character in Excel

A lot of time spent in Excel is used to clean up data that may not be immediately useful into something valuable. Being able to pull out everything to the left of a specific character can speed up and automate this process.


Contents:



Formula

This formula will return everything to the left of the "@" character from cell A1.

= LEFT(A1, (FIND("@", A1, 1) - 1))

If you have the latest version of Excel, you could use one of the new formulas TEXTBEFORE to return everything after a specific character as well:

= TEXTBEFORE(A1,"@")

Explanation

To return everything to the left of a specific character in a cell in Excel, we'll need to use the combine the LEFT function, which returns a specific number of characters from the beginning of a cell, and the FIND function to find the specific character.


= LEFT(A1, (FIND("@", A1, 1) - 1))

In this example, the formula is looking for the position of the "@" within the text in cell A1, and returning the position of "@" in the text, let's say it's 7.


The LEFT function is then used to extract the text from the left side of that specific character. In this case, the formula is using the text in cell A1 and the number of characters from the left, which is the value returned by the FIND function - 1 (since we do not want to include the character itself).


All combined, this formula leaves us with everything to the left of a specific character from any given cell.


Note:

This formula will only work if the specific character is present in the cell. If the character is not present, the FIND function will return an error. To avoid this error, you can use the IFERROR function to return an error message. For example:

= IFERROR(LEFT(A1, (FIND("@", A1, 1) - 1)), "Character not found")

This formula will return everything to the left of the "@" character if it is present in the cell, and will return the text "Character not found" if the "@" character is not present.



Examples

1. How to Extract First Name from Full Name

How to Extract First Name from Full Name in Excel

If we have a list of full name in column A, and want to pull out the first name in column B, we can use the following formula:

= LEFT(A1, (FIND(" ", A2, 1) - 1))

This formula will extract everything before the space, which in this case, is the first name.


If the full name is separated by a comma "," or a comma and a space ", " you can switch out the space in the above formula to get the same results.


2. How to Extract the Username from an Email Address

How to Extract the Username from an Email Address in Excel

Similarly, if we have a list of email addresses in column A, and want to pull out the username associated with each email address, we can use the following formula:

= LEFT(B3, (FIND("@", A2, 1) - 1))

This formula will extract everything before the "@" sign, leaving you the email username and removing the domain.


3. How to Extract the Street Address From a Full Mailing Address

How to Extract the Street Address From a Full Mailing Address in excel

We can also split up a full mailing address, and pull out the street address using the same method. In this example, we have a list of addresses in column A, and want to extract street address, we can use using the following formula:

= LEFT(B12, (FIND(",", A2, 1) - 1))

This formula will extract everything before the first "," pulling out the street address.


bottom of page