Function/VBA code to extract first & last name from email addresses

Shak1701

New Member
Joined
Nov 15, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a list of email address, in the format, 'Firstname.Lastname@Companyname.com'. My issue arises where multiple managers are serving the same function, these cells contain more than one email address in the aforementioned format, split by a ' ; '. Eg 'Firstname.Lastname@Companyname.com; 'Firstname.Lastname@Companyname.com ...'

Now I am only interested in extracting the first and last name of these managers, whether that be a single email address or a cell contains multiple. I understand the VBA function SPLIT will work, but I am unsure on how to code it.

Cell Formulas
RangeFormula
L998:L1004L998=RemoveDupeWords(K998,"; ")


I already have VBA code to remove duplicates.

Thank you in advance.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try this one

VBA Code:
Function jec(cell As String) As String
  Dim a As Variant, i As Long
  a = Split(cell, ";")
  
  For i = 0 To UBound(a)
    jec = jec & IIf(jec = "", "", ",") & Split(a(i), "@")(0)
  Next
End Function
 
Upvote 0
Try this one

VBA Code:
Function jec(cell As String) As String
  Dim a As Variant, i As Long
  a = Split(cell, ";")
 
  For i = 0 To UBound(a)
    jec = jec & IIf(jec = "", "", ",") & Split(a(i), "@")(0)
  Next
End Function
Thank you SO much JEC. I only have a slight issue now, how do I remove the '.' between the names?
 
Upvote 0
You're welcome!

Like this:
VBA Code:
Function jec(cell As String) As String
  Dim a As Variant, i As Long
  a = Split(cell, ";")
  
  For i = 0 To UBound(a)
    jec = jec & IIf(jec = "", "", ",") & Replace(Split(a(i), "@")(0), ".", " ")
  Next
End Function
 
Upvote 0
Solution

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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