I'm having problems trying extract email out of a string of data. How can extract only the email out of:|British Columbia|fere497@yahoo.com|1|778|387|9452. How do I do this when all the data and the emails have a different string count
I'm having problems trying extract email out of a string of data. How can extract only the email out of:|British Columbia|fere497@yahoo.com|1|778|387|9452. How do I do this when all the data and the emails have a different string count
Welcome to the forum!
[VBA]Sub Test_GetEmail()
MsgBox GetEmail("|British Columbia|fere497@yahoo.com|1|778|387|9452")
End Sub
Function GetEmail(barString As String, Optional sDelimiter As String = "|") As String
Dim element As Variant, Email As String
Email = ""
For Each element In Split(barString, sDelimiter)
If InStr(element, "@") Then
Email = element
Exit For
End If
Next element
GetEmail = Email
End Function[/VBA]