Extract multiple emails from one cell

Thomas Anderson

New Member
Joined
Sep 8, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Assuming all your data is in the format you show, here's a lightly-tested UDF you can try. After you install it, use it just like any worksheet function as shown in the example.

Book2
AB
1Jose Smith <JSmith@gmail.com>; Kelly Smith <Ksmith@gmail.com>; David Smith <DSmith@gmail.com>JSmith@gmail.com;Ksmith@gmail.com;DSmith@gmail.com
Sheet4
Cell Formulas
RangeFormula
B1B1=EmailList(A1)


VBA Code:
Function EmailList(S As String) As String
Dim FirstSplit, SecondSplit, i As Long, j As Long
FirstSplit = Split(S, ">;")
For i = LBound(FirstSplit) To UBound(FirstSplit)
    SecondSplit = Split(FirstSplit(i), "<")
    EmailList = EmailList & ";" & SecondSplit(1)
Next i
EmailList = Mid(EmailList, 2, Len(EmailList) - 2)
End Function
 
Upvote 0
Hi & welcome to MrExcel.
A formula option
+Fluff 1.xlsm
AB
1
2Jose Smith <JSmith@gmail.com>; Kelly Smith <Ksmith@gmail.com>; David Smith <DSmith@gmail.com>JSmith@gmail.com; Ksmith@gmail.com; DSmith@gmail.com
Master
Cell Formulas
RangeFormula
B2B2=TEXTJOIN("; ",,FILTERXML("<k><m>"&SUBSTITUTE(SUBSTITUTE(A2,"<",">"),">","</m><m>")&"</m></k>","//m[contains(.,'@')]"))
 
Upvote 0
Solution
Assuming all your data is in the format you show, here's a lightly-tested UDF you can try. After you install it, use it just like any worksheet function as shown in the example.

Book2
AB
1Jose Smith <JSmith@gmail.com>; Kelly Smith <Ksmith@gmail.com>; David Smith <DSmith@gmail.com>JSmith@gmail.com;Ksmith@gmail.com;DSmith@gmail.com
Sheet4
Cell Formulas
RangeFormula
B1B1=EmailList(A1)


VBA Code:
Function EmailList(S As String) As String
Dim FirstSplit, SecondSplit, i As Long, j As Long
FirstSplit = Split(S, ">;")
For i = LBound(FirstSplit) To UBound(FirstSplit)
    SecondSplit = Split(FirstSplit(i), "<")
    EmailList = EmailList & ";" & SecondSplit(1)
Next i
EmailList = Mid(EmailList, 2, Len(EmailList) - 2)
End Function

I just learned how to setup UDF. This works! Thank you Joe!
 
Upvote 0
Hi & welcome to MrExcel.
A formula option
+Fluff 1.xlsm
AB
1
2Jose Smith <JSmith@gmail.com>; Kelly Smith <Ksmith@gmail.com>; David Smith <DSmith@gmail.com>JSmith@gmail.com; Ksmith@gmail.com; DSmith@gmail.com
Master
Cell Formulas
RangeFormula
B2B2=TEXTJOIN("; ",,FILTERXML("<k><m>"&SUBSTITUTE(SUBSTITUTE(A2,"<",">"),">","</m><m>")&"</m></k>","//m[contains(.,'@')]"))
This was easier to implement than UDF and this works. Thank you Fluff!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top