# Formula to check if a date falls within a date range, then returns a corresponding cell

1. ## Formula to check if a date falls within a date range, then returns a corresponding cell

Hello,

I am trying to create a formula that will take a selected date, check to see which date range it falls in, and then have it return a cell that is the corresponding id number to the range. So for the file that I have attached, I want to take a specific date in the column "Date" check to see which range it falls in between the Start Date and End Date, and then have the ID that is associated with the date range put into column F, next to column E.  Register To Reply

2. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

Enter the following in F2 and drag it down: ``Please Login or Register  to view this content.``
Hope this helps.  Register To Reply

3. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

Try:

=INDEX(\$A\$2:\$A\$3,MATCH(1,INDEX((\$B\$2:\$B\$3<=E2)*(C2:C3>=E2),0),0))

copied down  Register To Reply

4. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

Thanks for the help. How would I change the formula so that it works if I have more date ranges and ID's to check. I posted an attachment of what it would look like.  Register To Reply

5. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

Use formula:

=INDEX(\$A\$2:\$A\$9,MATCH(1,INDEX((\$B\$2:\$B\$9<=E2)*(\$C\$2:\$C\$9>=E2),0),0))

copied down... and expand ranges as needed.  Register To Reply

6. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

Works great. Thanks a lot  Register To Reply

7. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

You are welcome.  Register To Reply

8. ## Re: Formula to check if a date falls within a date range, then returns a corresponding cel

I'm also learning the index and match functions.
I'm trying to build a formula that searches expenses by date and returns the sum of values only during that month.
This way I can have an endless expenses sheet and my monthly P&L searches for expenses that only occurred during that month.
I have attached sample data. This same formula could ultimately be used for income too.  Register To Reply

There are currently 1 users browsing this thread. (0 members and 1 guests) 