e-mail adres validation

M

Michael

Does anybody know how to check if an entered adres is a valid adres like:

[email protected]

and give a warning when something like this is entered: name.domain.com


txs in advance
Michael
 
F

Frank Kabel

Hi
one way: Enter the following code in one of your workbook modules

Public Function MailaddressOK(Adresse As String) As Boolean
Dim oVScriptRegEx As Object
Set oVScriptRegEx = CreateObject("VBScript.RegExp")
With oVScriptRegEx
.Pattern = "^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$"
MailaddressOK = .test(Adresse)
End With
End Function

you may have to register the VBSCRIPT object first in the VBE to use
regular expressions.

in your worksheet you can now enter the formula
=MailaddressOK(A1)
to check A1 for a valid email
 
Top