e-mail adres validation

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

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

(e-mail address removed)

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


txs in advance
Michael
 
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
 
Txs Frank,

I noticed that in some cases (ie: (e-mail address removed)) it doesnt work
correctly but its good enough for me.

Greetzs, Michael
 
Back
Top