Date Picker - Validation to only allow workdays


New Member
May 17, 2018

I have a User Form with a DatePicker. I want to Add validation so that only future workdays can be selected (excluding both weekends and Holidays).

  • Date Picker name = DTPickerLaunch
  • Validation occurs on command: Private Sub CommandButtonContinue_Click()
  • List of Holidays is located at 'Dropdown Values'!$J$19:$J$48

DTPickerLaunch currently defaults to today's date. I got as far as to validate that the field is changed but that was it. My code for the Command button is below.

Can someone help me to update the validation with the above criteria?

'When Click Continue from main page
Private Sub CommandButtonContinue_Click()

    'Check for Required Fields
           With Me
             If .TextBoxProductName.Value = "" Then Msg = Msg & "Product Name is required" & vbLf
             If .DTPickerLaunch = Date Then Msg = Msg & "Launch Date is required" & vbLf
             If .ComboBoxAffiliation = "" Then Msg = Msg & "Product Affiliation is required" & vbLf
             If .ComboBoxLabel = "" Then Msg = Msg & "Sdditional Product Label is required" & vbLf
             If .ComboBoxBrand = "" Then Msg = Msg & "Product Brand is required" & vbLf
             If .ComboBoxProductType = "" Then Msg = Msg & "Product Type is required" & vbLf
             If .ComboBoxProductType2 = "" Then Msg = Msg & "Indicate if Special/Hard Ticket Event is brand new" & vbLf
             If .ComboBoxMediaNeeded = "" Then Msg = Msg & "Indicate if Media is needed" & vbLf
           End With
        'That one option is checked for Product Contains
           For Each Ctrl In FrameChannels.Controls
             If TypeOf Ctrl Is MSForms.CheckBox Then
                  If Ctrl.Value = True Then
                        F1D = True
                        Exit For
                        End If
                  End If
              Next Ctrl
           If F1D = False Then
               Msg = Msg & "Selected at least one Product Channel (Pick all that Apply)"
           End If
        'Create one msg for all errors
            If Len(Msg) > 0 Then
                 MsgBox Msg
                 Exit Sub
             End If
    'Page Navagation
     If ComboBoxProductType = "Special Offer" Then
         MultiPage1.Value = 3
         MultiPage1.Value = 4
     End If

End Sub
Last edited:

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...