title: Excel VBA regular expression error
body: <p>Hello I'm having some issue tring to get the regular expression code  below to work.
  I'm getting a application-undefine or Object-Undefine error </p>
  
  <p>the text box is on  user form.</p>
  
  <p>the error is occurring on the line "Set allMatches = regEx.Execute(TextBox1.Text)"
  not sure what I missed.</p>
  
  <pre><code>Dim regEx As Object
  
  Dim allMatches As Object
  
  Set regEx = CreateObject("VBScript.RegExp")
  With regEx
          .IgnoreCase = True
          .MultiLine = False
          .Pattern = "\d{2,2}/\d{2,2}/\d{4,4} \d{2,2}:\d{2,2)[AM|PM]"
          .Global = True
  End With
  
  Set allMatches = regEx.Execute(TextBox1.Text)
  
  
  If allMatches.Count &lt;&gt; 0 Then
      result = allMatches.Item(0).submatches.Item(0)
  End If
  </code></pre>