View Full Version : Extract email out of changing string count
obabs
07-22-2011, 09:32 AM
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
Kenneth Hobs
07-22-2011, 10:29 AM
Welcome to the forum!
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.