Fetching the One email ID from many

ganeshvenkatram84

New Member
Joined
Jun 9, 2011
Messages
4
Hi All,
In my project, there is a field in excel sheet which contains one or more email address like,
ABC@yahoo.com/ABCD@gmail.com.
I need to fetch first email ID alone(ABC@yahoo.com). I dont know to to retrieve like that.
Plz help me out since im new to VBA.I need to finish my project early

Ganesh.V
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
UDF

Code:
Function ExtractEmail(str As String) As String
    ExtractEmail = Split(str, "/")(0)
End Function
 
Upvote 0
Hi sektor

Thanks for ur timely reply.Your code works absolutely fine. Many thanks

I have one more doubt
I have used the below code for email validation

Private Sub TxtEmail1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With CreateObject("vbscript.regexp")
.Pattern = "^[\w-\.]+@([\w-]+\.)+[A-Za-z]{2,3}$"
If .test(TxtEmail1.Value) Then
MsgBox "OK"
Else
MsgBox "No good"
Cancel = True
End If
End With
End Sub

The code works fine. But in some cases its not working for the following example
Example : <TABLE style="WIDTH: 188pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=250 border=0 x:str><COLGROUP><COL style="WIDTH: 188pt; mso-width-source: userset; mso-width-alt: 9142" width=250><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl25 style="BORDER-LEFT-COLOR: #e0dfe3; BORDER-BOTTOM-COLOR: #e0dfe3; WIDTH: 188pt; BORDER-TOP-COLOR: #e0dfe3; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; BORDER-RIGHT-COLOR: #e0dfe3" width=250 height=17 x:str="'amrit.boricha@gmail.com.com">amrit.boricha@gmail.com.com
it shows that the above email id is valid
</TD></TR></TBODY></TABLE>
Please Assist <!-- / message -->
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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