Select Case To Check Date Ranges

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
Hi Guys,

I am using the below code to do checks for a automated holiday spreadsheet. if first checks to see if the user has enough holiday "<26" and then checks to see if they are not trying to request more that 10 days " < 10 ". the dates are declared in two cells From " B21" To "C21"

what I wanted to know if anyone knows a way that I could declare dates that are not allowed to be requested?

So if 20/12/2017-25/12/2017 was requested it would run a error message.

any help would be greatly appreciated

Jamie

Code:
Sub TooManyHolidays()Dim msg As String
Dim Ans As VbMsgBoxResult


    If Sheets("Request Form").Range("B14") < 26 And Sheets("Request Form").Range("E21") < 10 Then
        NewBookingCheck.NewBookingCheck
    ElseIf Sheets("Request Form").Range("B14") >= 26 Then
        msg = (" You Dont Have Enough Holiday! Would You Like To Continue? ")
        Ans = MsgBox(msg, vbYesNo)
        If Ans = vbNo Then
            Sheets("Request Form").Select
            Range("Employee3").ClearContents
            Range("DateRequest").ClearContents
                Application.DisplayAlerts = False
                ThisWorkbook.Save
                Application.DisplayAlerts = True
                WorkbookClose
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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