Results 1 to 5 of 5

Error validating a inputbox with regular expressions

Threaded View

  1. #1
    Registered User
    Join Date
    05-12-2021
    Location
    México
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (16.0.13530.20054)
    Posts
    17

    Error validating a inputbox with regular expressions

    Dear experts:

    Hope you are having a great week!

    I'm having a hard time validating the information provided on an inputbox, it must be an email from the outlook domain. This is the code I'm using to evaluate the email provided (ROemail)

            ROemail = Application.InputBox("Please enter your email to receive notifications about the status of this format.", Title:="Risk owner Email address", Default:="email@outlook.com", Type:=2)
                If StrPtr(ROemail) = 0 Then
                    MsgBox ("Action cancelled by user. QA not requested!")
                    Exit Sub
                ElseIf ROemail = vbNullString Then
                    MsgBox ("No email entered. Please provide a valid email")
                Else
                    If ValidateEmailAddress(ROemail) = False Then
                            MsgBox ("The information provided is not a valid email from the Outlook domain, please verify.")
                    Else
    		        'DO STUFF
                    End If
    	    End If
    The Function ValidateEmailAddress() that validates the String goes like this:

    Public Function ValidateEmailAddress(ByVal ROemail As String) As Boolean
        On Error GoTo Catch
        
        Dim objRegExp As Object
        Dim blnIsValidEmail As Boolean
        
        objRegExp.IgnoreCase = True
        objRegExp.Global = True
        objRegExp.Pattern = "^(([\w\d\-\_\.])+@outlook\.com,*\s*)+$"
        
        blnIsValidEmail = objRegExp.Test(ROemail)
        ValidateEmailAddress = blnIsValidEmail
          
        Exit Function
        
    Catch:
        ValidateEmailAddress = False
    End Function
    But for some reason it's not working and it's sending me this errors related to the objRegExp, It's the first time using a function and a Regular Expression so I'm not sure if I'm doing something wrong or something is missing.

    Could you please advice me?

    Thank you so much in advance!
    Attached Images Attached Images
    Last edited by Magmarinita; 06-25-2021 at 05:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Regular Expressions in VBA
    By BS Singh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2014, 03:29 PM
  2. Regular Expressions in VBA
    By samualt in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-08-2011, 11:34 PM
  3. VBA . validating user entered data (via inputbox) and error handler
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2011, 05:54 PM
  4. Regular Expressions
    By mattdick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-07-2009, 06:33 PM
  5. Regular expressions
    By JeffMelton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2006, 09:00 PM
  6. [SOLVED] Error while Checking for Regular Expressions Library in VBA
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2005, 06:05 PM
  7. Regular Expressions in VBA?
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-10-2005, 02:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1