Invalid Email Id

hardeep.kanwar

Well-known Member
Joined
Aug 13, 2008
Messages
693
Hi!

I have 21000 E-Mail ID's

But Some have in Wrong Format, Now i want to know which one are InValid E-Mail ID's

Right Now i am Using this<TABLE style="WIDTH: 161pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=215><COLGROUP><COL style="WIDTH: 161pt; mso-width-source: userset; mso-width-alt: 7862" width=215><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; BACKGROUND-COLOR: transparent; WIDTH: 161pt; HEIGHT: 15pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3" id=td_post_1507436 class=xl67 height=20 width=215>ISNUMBER(FIND(".",A2,FIND("@",A2)))



</TD></TR></TBODY></TABLE>Formula

but its not Working Properly, It show True Even The EMAIL-ID IS WRONG.

See Below

Sheet3

image removed


Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4


Thanks in Advance
 
Last edited by a moderator:
How about

Code:
Function ValidateEmail(Email As String) As String
    Dim oRegExp As Object
    Set oRegExp = CreateObject("vbscript.regexp")
    With oRegExp
        .Global = True
        .Pattern = "^[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{3}$"
        If .test(Email) Then
            ValidateEmail = "Valid Email"
        Else
            ValidateEmail = "Invalid Email"
        End If
    End With
End Function

image removed
Cell Formulas
RangeFormula
B2=ValidateEmail(UPPER(A2))
 
Last edited by a moderator:
Upvote 0
Hi!

Thanks for Reply

I Tried your Code, but in Many Cases it Shows Wrong Result

See Below

image removed

<TABLE style="BORDER-BOTTOM-STYLE: groove; BORDER-BOTTOM-COLOR: #00ff00; BORDER-RIGHT-STYLE: groove; BACKGROUND-COLOR: #fffcf9; BORDER-TOP-COLOR: #00ff00; FONT-FAMILY: Arial; BORDER-TOP-STYLE: groove; COLOR: #000000; BORDER-RIGHT-COLOR: #00ff00; FONT-SIZE: 10pt; BORDER-LEFT-STYLE: groove; BORDER-LEFT-COLOR: #00ff00"><TBODY><TR><TD>Spreadsheet Formulas</TD></TR><TR><TD><TABLE style="FONT-FAMILY: Arial; FONT-SIZE: 9pt" border=1 cellSpacing=0 cellPadding=2><TBODY><TR style="BACKGROUND-COLOR: #cacaca; FONT-SIZE: 10pt"><TD>Cell</TD><TD>Formula</TD></TR><TR><TD>F2</TD><TD>=ValidateEmail(UPPER(D2))</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4


These All are VALID E-MAIL ID'S
 
Last edited by a moderator:
Upvote 0
Yup... the current code expects only a single "." after the "@"... Lets see if I can modify it to include 2 periods...
 
Upvote 0
building on Sandeeps' solution,

Code:
Function ValidateEmail(ByVal Email As String) As String
With CreateObject("vbscript.regexp")
    .Global = True
    .Pattern = "^[\w-\.]+@\w+\.[a-z]+(\.[a-z]+)?$"
    If .test(LCase(Email)) Then
        ValidateEmail = "Valid Email"
    Else
        ValidateEmail = "Invalid Email"
    End If
End With
End Function

this allows, any alphanumeric, period (.), hypen and underscore in both the user name and the domain name, the suffix of domain name (.com,.co.in) can contain only alphabets
 
Upvote 0
Good one Sankar...

I was tryin out a few combinations... any idea why this didn't work??

Code:
.Pattern = "^[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,3}+\.[A-Z]{3}$"
 
Upvote 0
Good one Sankar...

I was tryin out a few combinations... any idea why this didn't work??

Code:
.Pattern = "^[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,3}+\.[A-Z]{3}$"


not very sure, let me try and lets see if any of the masters have a look into this,

while evaluating the pattern in parts,

Code:
[A-Z]{2,3}+

the above gave an error, this is because, the numbers in the curly braces denote the min and max length of the word to be matched, the + sign next would result in an error, as it means, one or more of the previous character,

we can rewrite that part in two ways,

Code:
([A-Z]{2,3})+

this would result in removing the last part of the pattern as it is redundant, the whole pattern would be
Code:
.Pattern = "^[A-Z0-9._-]+@[A-Z0-9-]+(\.[A-Z]{2,3})+$"

the above pattern would match email address removed

if we want to restrict the domain name to have maximum of 3 parts then,

Code:
.Pattern = "^[A-Z0-9._-]+@[A-Z0-9-]+(\.[A-Z]{2,3}){1,2}$"

would do
 
Last edited by a moderator:
Upvote 0
Hardeep,

Are these "real" emails addresses? If so, we probably want to remove them. Spammer and Spambots routinely patrol public forums like these looking for email addresses. People might become real upset with you if they start getting Spam because you posted their email address!

If so, let me know and I can remove all the images that contain the email addresses.

The Moderators
 
Upvote 0
Hardeep,

Are these "real" emails addresses? If so, we probably want to remove them. Spammer and Spambots routinely patrol public forums like these looking for email addresses. People might become real upset with you if they start getting Spam because you posted their email address!

If so, let me know and I can remove all the images that contain the email addresses.

The Moderators


Hi! Sir,

Some have Real and Some Don't have.

Could you Pls Remove all the Images for me

I will be Very Thankful to You.
 
Upvote 0

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