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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,221,483
Messages
6,160,093
Members
451,617
Latest member
vincenzo1

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