Date Picker - Validation to only allow workdays

JustHooch

New Member
Joined
May 17, 2018
Messages
44
Hello,

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?

Code:
'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
     Else
         MultiPage1.Value = 4
     End If


End Sub
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top