Public Function patron(referencia) Dim objRegex As VBScript_RegExp_55.RegExp Dim colMatch As VBScript_RegExp_55.MatchCollection Dim vbsMatch As VBScript_RegExp_55.Match Dim colSubMatch As VBScript_RegExp_55.SubMatches Dim sMatchString As String Dim i, num, numT As Integer Set objRegex = New VBScript_RegExp_55.RegExp objRegex.IgnoreCase = True objRegex.Global = True objRegex.Pattern = "[^A-Za-z ]+" Set colMatch = objRegex.Execute(referencia) numT = colMatch.Count objRegex.Pattern = "[A-Za-z ]+" Set colMatch = objRegex.Execute(referencia) num = colMatch.Count On Error GoTo ControlErrores If numT = 0 And num >= 0 Then patron = 1 Else patron = 2 End If Exit Function ControlErrores: MsgBox ("en patron " & Err.Number) Select Case Err.Number Case 13 Case 9 Exit Function End Select End Function