Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Formula to check email address


Is there a formula where I can use to check if the email address is
valid or not? Help is much appreciated.




--
ljCharlie
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Formula to check email address

Add this VBA function


'-----------------------------------------------------------------
Public Function ValidEmail(Adress As String) As Boolean
'-----------------------------------------------------------------
Dim oRegEx As Object
Set oRegEx = CreateObject("VBScript.RegExp")
With oRegEx
.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' .Pattern = "^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$"
ValidEmail = .Test(Adress)
End With
Set oRegEx = Nothing
End Function


and use like

)

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ljCharlie" wrote in message
...

Is there a formula where I can use to check if the email address is
valid or not? Help is much appreciated.




--
ljCharlie



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Formula to check email address

On Mon, 19 Feb 2007 21:38:26 +0000, ljCharlie
wrote:


Is there a formula where I can use to check if the email address is
valid or not? Help is much appreciated.


Well, you won't really know if an email address is valid until you try to send
email to that address.

And if you accept all of the variations allowed in the official RFC 822
http://www.ietf.org/rfc/rfc0822.txt standard, your task would be quite
complex, and your email client probably wouldn't be able to handle some of the
valid email addresses.

Do you want to limit to a list of certain top level domains? (e.g. .nu .ru .
il .com .org .net .edu .museum) or do you want to allow any series of 2 to 3 or
4 or 6 characters?

Do you want to limit to only English characters? Or can you allow non-English
characters?

Will the email address to be checked be the only item in the text string? Or
might it be embedded in a longer string?

And so forth.

So you'll need to define how you want a valid email address to appear. Once
you've done that, you can use a Regular Expression using either a UDF or, more
simply, a function in Longre's free morefunc.xll add-in http://xcell05.free.fr/


--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Formula to check email address


Many thanks for the help. By valid I mean an email address should have a
quotation, apostrophe, period, colon, and semicolon at the end or in
some part of the email address where it's not suppose to be.




--
ljCharlie
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Formula to check email address


Bob Phillips Wrote:
Add this VBA function


'-----------------------------------------------------------------
Public Function ValidEmail(Adress As String) As Boolean
'-----------------------------------------------------------------
Dim oRegEx As Object
Set oRegEx = CreateObject("VBScript.RegExp")
With oRegEx
.Pattern =
"^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' .Pattern = "^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$"
ValidEmail = .Test(Adress)
End With
Set oRegEx = Nothing
End Function


and use like

)



How do I modify the code so that I can specify an email column?




--
ljCharlie


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Formula to check email address

On Tue, 20 Feb 2007 13:40:17 +0000, ljCharlie
wrote:


Many thanks for the help. By valid I mean an email address should have a
quotation, apostrophe, period, colon, and semicolon at the end or in
some part of the email address where it's not suppose to be.


What you write doesn't make sense to me. Even if you were describing an invalid
rather than a valid address, you need to define where you think these
particular characters are not supposed to be, other than at the end.


But try this: Download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr/

Then use this formula which will return TRUE or FALSE depending on whether an
email address might be valid.

=REGEX.COMP(A1,"(^|\b)[\w._%-]+@[\w.-]+\.[A-Za-z]{2,4}(\b|$)")

A valid email address is defined as:

Starts either at the beginning of the text string or after a word break

The part before the "@" consists of any combination of English letters, digits,
dot, underscore, percent sign or dash.

@

The part after the "@" but before the terminal dot consists of any combination
of English letters, digits, dot or dash.

.. (dot)

The domain is any combination of English letters that is two to four characters
in length.

If you want something more comprehensive, you'll need to post back.
--ron
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Formula to check email address

This a UDF as given. Do you mean that you want to validate a single cell, a
column of cells?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ljCharlie" wrote in message
...

Bob Phillips Wrote:
Add this VBA function


'-----------------------------------------------------------------
Public Function ValidEmail(Adress As String) As Boolean
'-----------------------------------------------------------------
Dim oRegEx As Object
Set oRegEx = CreateObject("VBScript.RegExp")
With oRegEx
.Pattern =
"^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' .Pattern = "^(\w+\.)*(\w+)@(\w+\.)+([a-zA-Z]{2,4})$"
ValidEmail = .Test(Adress)
End With
Set oRegEx = Nothing
End Function


and use like

)



How do I modify the code so that I can specify an email column?




--
ljCharlie



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i convert an email address to a web address Arvind Sikar Excel Worksheet Functions 3 October 3rd 06 08:06 PM
can I copy a column of email addresses, paste into email address? Lizizfree New Users to Excel 4 July 20th 06 10:03 PM
Transfer Email addresses from spreadsheet to email address book Beana Excel Discussion (Misc queries) 2 May 30th 06 06:07 PM
how do I sort email address, dedupes,check for errors in a docume. varun Excel Discussion (Misc queries) 2 January 14th 05 11:41 PM
Shut off email address from linking to email program? Java Jake Excel Worksheet Functions 6 December 31st 04 04:05 PM


All times are GMT +1. The time now is 08:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"