EMAILVALID
EMAILVALID(sEmailAddress)
Returns whether a string is a valid email address.
| sEmailAddress |
REMARKS
Public Function EMAILVALID( _
Public Function EMAILVALID( _
ByVal sEmailAddress As String) _
As Boolean
Dim sEmailPattern1 As String
Dim sEmailPattern2 As String
Dim oRegEx As Object
Dim bReturn As Boolean
sEmailPattern1 = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$"
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Global = True
oRegEx.IgnoreCase = True
oRegEx.Pattern = sEmailPattern1
bReturn = False
If (oRegEx.Test(sEmailAddress) = True) Then
sEmailPattern2 = "^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Global = True
oRegEx.IgnoreCase = True
oRegEx.Pattern = sEmailPattern2
bReturn = False
If (oRegEx.Test(sEmailAddress) = True) Then
bReturn = True
Else
bReturn = False
End If
Else
bReturn = False
End If
EMAILVALID = bReturn
End Function
For instructions on how to add this function to a workbook refer to the page under Inserting Functions
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext