Code:
Public Function blnEmailValid(ByVal strEmailAdd As String) As Boolean
With CreateObject("VBScript.RegExp")
.IgnoreCase = True
.Global = True
.Pattern = "^([a-zA-Z0-9_\-\.]+)@[mindef]+(\.[a-z0-9-]+)*(\.[nl]{2,3})$"
blnEmailValid = .Test(strEmailAdd)
End With
End Function
Sub checkMail()
mailwaarde = Range("email")
Application.Goto Reference:="email"
Selection.Hyperlinks.Delete
'ActiveCell.Range("A1:L1").Select
If blnEmailValid(mailwaarde) = True Then
Application.Goto Range("reeds")
Else
MsgBox "U heeft GEEN geldig emailadres ingevoerd" & vbNewLine _
& "============================================" & vbNewLine & vbNewLine _
& "Dit mailadres MOET het einde hebben van: @bedrijf.nl !!! En mag geen spaties bevatten."
Application.Goto Range("email")
Range("reeds").Select
Range("email").Select
End If
End Sub
Als de extensie NN is en ".nl" wordt getyped, ziet de macro 'm toch als een correct mailadres..
Wat zie ik over het hoofd.....?