Hobolord
Board Regular
- Joined
- Sep 9, 2015
- Messages
- 64
I currently have the below code that gives me the first name of someone from their email (assuming their email is in the format Firstname.Lastname@Email.com).
I need to also have a way to get the last name, and I'm terrible with the mid function. Would anyone be able to assist with the VBA code that would be able to provide the last name from an email address in the format Firstname.Lastname@email.com?
Thank you in advance!
Edit: Formatting
Code:
Sub Email ()
Dim EmailAddress As String
Dim Name As String
EmailAddress = Sheets("Detail").Range("A3").Value
Position = 0
Char = "Z"
Do Until Char = "."
Position = Position + 1
Char = Mid(EmailAddress, Position, 1)
Loop
NameL = Position - 1
Name = Left(EmailAddress, NameL)
Msgbox (Name)
End Sub
I need to also have a way to get the last name, and I'm terrible with the mid function. Would anyone be able to assist with the VBA code that would be able to provide the last name from an email address in the format Firstname.Lastname@email.com?
Thank you in advance!
Edit: Formatting
Last edited: