Results 1 to 2 of 2

Userform Validation - combining code?

Threaded View

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Userform Validation - combining code?

    Userform is adding info for up to 20 people (Potential for 8 adults labeled Adult1, adult2..... and 12 children labeled Child1, child 2....)

    for each of the people, I have to run the same validations.

    1. If a first name is entered there MUST be a last name entered
    2. If a last name is entered there MUST be a first name entered
    3. If a first name and last name is entered a DOB must be entered
    4. If a first name and last name is entered then a validation yes/no box is to be checked.

    I am basically looking to try and combine the macro code behind the scenes in an effort to optimize.

    Example of DOB Validation code is

    is there any way to do this?
    Private Sub TextBox14_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        If DisableEvents Then Exit Sub
    
           If Me.TextBox12.Value <> "" Or Me.TextBox13.Value <> "" Then
     
                If Not TextBox14.Value Like "##[/]##[/]####" Then
                    MsgBox "Adult 1 DOB Must Be in the Format of mm/dd/yyyy"
                           Cancel = True
                           TextBox14.Value = ""
                Else
    
                If DateValue(TextBox14.Value) > DateValue(Now) Then
                    MsgBox "Adult 1 DOB Must be in the Past"
                           Cancel = True
                           TextBox14.Value = ""
            
                Else
                           TextBox14.SetFocus
                End If
            End If
        End If
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Userform textbox validation - non-existent date validation
    By rbngrt582 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2018, 10:14 PM
  2. Combining my userform with a userform template - 'find' and 'amend' feature
    By excelconditional in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2017, 04:13 AM
  3. [SOLVED] Userform for canadian postal code validation?
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2014, 01:03 PM
  4. combining code to have userform get data from 1 sheet and transfer to another
    By James__S in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2014, 03:26 AM
  5. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-04-2014, 07:11 AM
  6. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2014, 12:28 PM
  7. [SOLVED] Combining Validation (empty and numeric) Code for ActiveX Text Box
    By VB@N3wb|3 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-13-2012, 10:22 PM

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