Check if Date is Inbetween Dates

The following VBA function will check if a given date is between two other dates and if so, it will return the value TRUE. If the date is not in between the dates, then it will return the value FALSE.

The function has three arguments:
• Start_ date – the earliest allowable date
• End_ Date – the latest allowable date
• Other_Date – the date being compared

The function must be in an Excel module. It can be run from an Excel Workbook e.g:

A4= Compare_Dates(21-06-2003,12-02,2008,15-09-2008)
A3 =Compare_Dates(A1,A2.A3)
A1= Compare_Dates(13-03-2005,18-08-2005,A6)
So Compare_Dates(25-04-2007,12-07-2008, 23-06-2006) will give the value TRUE as 23-06-2006 is between 25-04-2007 and 12-07-2008.

Likewise Compare_Dates(19-07-2003,12-12-2001,12-08-2008) will return FALSE as 12-12-2001 is NOT between 19-07-2003 and 12-08-2008

Download .XLSM function here

VBA Coding Made Easy

Stop searching for VBA code online. Download our free add-in to quickly insert any of the sample code found on our site into the Visual Basic Editor.

alt text

Stop searching for VBA code online. Try the Code VBA Add-in…

Free Download!


<<Return to VBA Examples

Did you find this VBA tutorial useful? Then share it with your friends and colleagues: