Check E-Mail address entry is valid ???

Chris72

Board Regular
Joined
Jun 11, 2007
Messages
115
One cell in my worksheet requires an e-mail address entry.

What formula can be derived that checks the validity of the entry as an e-mail address?

Regards,

Chris....
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
The only criteria I can think of for a valid email address is contains an @ and a . at some point AFTER the @

this should check that criteria....

=AND(ISNUMBER(FIND("@",A1)),ISNUMBER(FIND(".",A1,FIND("@",A1))))
 
Upvote 0
Or via VBA via Regular Expressions...



<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Function</SPAN> IsValidEmail(Value <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN><br><SPAN style="color:#007F00">'Originally from Tommy Gun</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> RE <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN><br>    <SPAN style="color:#00007F">Set</SPAN> RE = CreateObject("vbscript.RegExp")<br>    RE.Pattern = "^[a-zA-Z0-9\._-]+@([a-zA-Z0-9_-]+\.)+([a-zA-Z]{2,3})$"<br>    IsValidEmail = RE.Test(Value)<br>    <SPAN style="color:#00007F">Set</SPAN> RE = <SPAN style="color:#00007F">Nothing</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN></FONT>



HTH
 
Upvote 0
FIREFYTR (Zack) - I will try this one a little later when I have put everything to bed.

PS: So who's who in the picture are you the Prince or the lovely Princess? :)
 
Upvote 0
Another way
Code:
Public Function GoodEmail(iEmail As String) As Boolean
    GoodEmail = IIf(iEmail Like "*@*.*", True, False)
End Function

Formula
=IF(GoodEmail(A3)," ","Please Correct email, it appears to be invalid")
 
Upvote 0
The reason for the regexp is the addition of the special characters check. When you use the * wildcard, you are really leaving the field open for anything to be used, and not all characters are valid in email addresses. Of course there are pros and cons to all solutions. :)
 
Upvote 0
No doubt about it! :)

My post is a quick and dirty for normal data entry.:biggrin:
It would not work at all if the e-mail was being entered through other means. I am offering another way other than loading the regexp on each entry.:ROFLMAO:
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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