Reputation: 3073
Trying to extract the email from a column in an excel sheet using the following formula:
=TRIM(MID(SUBSTITUTE(" "&$A1&" "," ",REPT(" ",40)),
FIND(REPT("@",COLUMNS($A1:A1)),SUBSTITUTE
(SUBSTITUTE(" "&$A1&" "," ",REPT(" ",40)),"@",REPT("@",COLUMNS($A1:A1)),COLUMNS($A1:A1)))-40,80))
The formula works for the most part, however some of the records still include other text.
For example, one of the records looks like this:
**TEST** John Beasley,[email protected],7575551212
After using the above formula, I get the following results:
Beasley,[email protected],7575551212
Here's another example:
USA-USA/J Beasley/[email protected]/757-555-1212
Results after using formula:
Beasley/[email protected]/757-555-1212
Here is an example of when the formula works (before):
**US AMA TES DATA** John Beasley, [email protected]
Which yields the following results:
[email protected]
So the formula works, but it also does not work.
How can I write the formula so that it extracts everything except the actual email address?
Upvotes: 0
Views: 189
Reputation: 152505
If one has it, use FILTERXML:
=FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,"/",","),",","</s><s>")&"</s></t>","//s[contains(.,'@')]")
FILTERXML was introduced in Excel 2013 and only on PC not Mac.
If does not have FILTERXML then we can use:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"/",","),",",REPT(" ",999)),FIND("@",SUBSTITUTE(SUBSTITUTE(A1,"/",","),",",REPT(" ",999)))-500,999))
Upvotes: 1