Excel - FIND Function

FIND returns the position of one text string in another text string. For example, you may want to know position of "@" in an email address. If we know position of "@" in an email address, we can further extract the domain name of an email address.

Suppose you have a list of email addresses below.



1. Find position of "@" in the email address. The formula is:

=FIND("@", A2)

For example, "@" is the 6th character in the "alice@apple.com", so it returns a value of 6.



2. Calculate length of email address, the LEN function is used.

=LEN(A2)



3. Based on length of an email address and position of "@" in it, we use MID function to extract the domain name.

=MID(A2, B2+1, C2-B2)

"B2+1" is the first character after the "@" sign, which is 7 in the first email address. "C2-B2" is the number of characters after the "@", which is 9 in the first email address. The MID function reads the email address and grab 9 characters starting from position 7. Below is the extract domain name.



4. You can combine all these 3 functions in one formula. But be careful when writing complex formulas since they are error-prone. If possible, do it in multiple little steps like above.

=MID(A2,FIND("@",A2)+1,LEN(A2)-FIND("@", A2))


Comments

Popular posts from this blog

Excel - IF function

Excel - VLOOKUP function

Excel - Hierarchical chart (Treemap)