title: How to validate email address format?
body: <p>I am creating a userform on which the user must enter certain information.</p>
  
  <p>For example, I would like to make a condition or code to inform the user that he must enter a valid email address, and not only a msgbox because he can click OK and continue without modifying his email address.</p>
  
  <p>I found this code but I found it hard to understand. What does it mean?</p>
  
  <pre><code>Function ValidEmail(eMail As String) As Boolean
      Dim MyRegExp As RegExp
      Dim myMatches As MatchCollection
      Set MyRegExp = New RegExp
      MyRegExp.Pattern = "^[a-z0-9_.-]+@[a-z0-9.-]{2,}\.[a-z]{2,4}$"
      MyRegExp.IgnoreCase = True
      MyRegExp.Global = False
      Set myMatches = MyRegExp.Execute(eMail)
      ValidEmail = (myMatches.Count = 1)
      Set myMatches = Nothing
      Set MyRegExp = Nothing
  End Function
  </code></pre>