*The tutorial shows how to use an Excel IF formula to see if a given number or date falls between two values.*

To check if a given value is between two numeric values, you can use the AND function with two logical tests. To return your own values when both expressions evaluate to TRUE, nest AND inside the IF function. Detailed examples follow below.

## Excel formula: if between two numbers

To test if a given number is between two numbers that you specify, use the AND function with two logical tests:

- Use the greater then (>) operator to check if the value is higher than a smaller number.
- Use the less than (<) operator to check if the value is lower than a larger number.

The generic *If between* formula is:

*value*>

*smaller_number*,

*value*<

*larger_number*)

To include the boundary values, use the greater than or equal to (>=) and less than or equal to (<=) operators:

*value*>=

*smaller_number*,

*value*<=

*larger_number*)

For example, to see if a number in A2 falls between 10 and 20, not including the boundary values, the formula in B2, copied down, is:

`=AND(A2>10, A2<20)`

To check if A2 is between 10 and 20, including the threshold values, the formula in C2 takes this form:

`=AND(A2>=10, A2<=20)`

In both cases, the result is the Boolean value TRUE if the tested number is between 10 and 20, FALSE if it is not:

### If between two numbers then

In case you want to return a custom value if a number is between two values, then place the AND formula in the logical test of the IF function.

For example, to return "Yes" if the number in A2 is between 10 and 20, "No" otherwise, use one of these IF statements:

If between 10 and 20:

`=IF(AND(A2>10, A2<20), "Yes", "No")`

If between 10 and 20, including the boundaries:

`=IF(AND(A2>=10, A2<=20), "Yes", "No")`

Tip. Instead of hardcoding the threshold values in the formula, you can input them in individual cells, and refer to those cells like shown in the below example.

Suppose you have a set of values in column A and wish to know which of the values fall between the numbers in columns B and C in the same row. Assuming a smaller number is always in column B and a larger number is in column C, the task can be accomplished with this formula:

`=IF(AND(A2>B2, A2<C2), "Yes", "No")`

Including the boundaries:

`=IF(AND(A2>=B2, A2<=C2), "Yes", "No")`

And here is a variation of the *If between* statement that returns a value itself if TRUE, some text or an empty string if FALSE:

`=IF(AND(A2>10, A2<20), A2, "Invalid")`

Including the boundaries:

`=IF(AND(A2>=10, A2<=20), A2, "Invalid")`

### If boundary values are in different columns

When smaller and larger numbers you are comparing against may appear in different columns (i.e. number 1 is not always smaller than number 2), use a slightly more complex version of the formula.

*value*> MIN(

*num1*,

*num2*),

*value*< MAX(

*num1*,

*num2*))

Here, we first test if the target value is higher than a smaller of the two numbers returned by the MIN function, and then check if it is lower than a larger of the two numbers returned by the MAX function.

To include the threshold numbers, adjust the logic as follows:

*value*>= MIN(

*num1*,

*num2*),

*value*<= MAX(

*num1*,

*num2*))

For example, to find out if a number in A2 falls between two numbers in B2 and C2, use one of these formulas:

Excluding boundaries:

`=AND(A2>MIN(B2, C2), A2<MAX(B2, C2))`

Including boundaries:

`=AND(A2>=MIN(B2, C2), A2<=MAX(B2, C2))`

To return your own values instead of TRUE and FALSE, use the following Excel IF statement between two numbers:

`=IF(AND(A2>MIN(B2, C2), A2<MAX(B2, C2)), "Yes", "No")`

Or

`=IF(AND(A2>=MIN(B2, C2), A2<=MAX(B2, C2)), "Yes", "No")`

## Excel formula: if between two dates

The *If between dates* formula in Excel is essentially the same as *If between numbers*.

To check whether a given date is within a certain range, the generic formula is:

*date*>=

*start_date*,

*date*<=

*end_date*), value_if_true, value_if_false)

Not including the boundary dates:

*date*>

*start_date*,

*date*<

*end_date*), value_if_true, value_if_false)

However, there is a caveat: IF does recognize dates supplied directly to its arguments and regards them as text strings. For IF to recognize a date, it should be wrapped in the DATEVALUE function.

For example, to test if a date in A2 falls between 1-Jan-2022 and 31-Dec-2022 inclusive, you can use this formula:

`=IF(AND(A2>=DATEVALUE("1/1/2022"), A2<=DATEVALUE("12/31/2022")), "Yes", "No")`

In case, the start and end dates are in predefined cells, the formula becomes much simpler:

`=IF(AND(A2>=$E$2, A2<=$E$3), "Yes", "No")`

Where $E$2 is the start date and $E$3 is the end date. Please notice the use of absolute references to lock the cell addresses, so the formula won't break when copied to the below cells.

Tip. If each tested date should fall in its own range, and the boundary dates may be interchanged, then use the MIN and MAX functions to determine a smaller and larger date as explained in If boundary values are in different columns.

### If date is within next N days

To test if a date is within the next *n* days of today's date, use the TODAY function to determine the start and end dates. Inside the AND statement, the first logical test checks if the target date is greater than today's date, while the second logical test checks if it is less than or equal to the current date plus *n* days:

*date*> TODAY(),

*date*<= TODAY()+

*n*), value_if_true, value_if_false)

For example, to test if a date in A2 occurs in the next 7 days, the formula is:

`=IF(AND(A2>TODAY(), A2<=TODAY()+7), "Yes", "No")`

### If date is within last N days

To test if a given date is within the last *n* days of today's date, you again use IF together with the AND and TODAY functions. The first logical test of AND checks if a tested date is greater than or equal to today's date minus *n* days, and the second logical test checks if the date is less than today:

*date*>= TODAY()-

*n*,

*date*< TODAY()), value_if_true, value_if_false)

For example, to determine if a date in A2 occurred in the last 7 days, the formula is:

`=IF(AND(A2>=TODAY()-7, A2<TODAY()), "Yes", "No")`

Hopefully, our examples have helped you understand how to use the *If between* formula in Excel efficiently. I thank you for reading and hope to see you on our blog next week!

## Practice workbook

Excel If between - formula examples (.xlsx file)

## 136 comments

=IF(OR(C3>=DATEVALUE("2/19/2024"), C3<=DATEVALUE("2/25/2024")),K3, 0)

I am trying to use a date range to select data on the same spread sheet in a different cell. If the reference cell meets the date range then the value in the "true" referenced cell, if not then enter a zero. I have tried the above formular however, it doesn't work. Any suggestions?

I would very much appreciate if someone could explain to me how to make excel calculate the following:

Date Range using the if formula

My spreadsheet is comprised of names dates and then blank boxes for the 12 months of the year. I would like if excel could use the dates and place an x in each months box that corresponds to the date range. Example date range 1/12023 - 3/30/2021 it would place an x in January February and march and leave all the other boxes blank.

Hi! Your sample date range is text. Therefore, you cannot perform any calculations with it, including calculating months.

i want to assign a new value , if the number falls in between two numbers . there are ten such two number in 10 ten row

Hi! Have you tried the ways described in this blog post? If they don’t work for you, then please describe your task in detail.

Looking for a little help I want to make a cell auto fill a number The formula I have now is =IF(AND(C19>=150,C19<=149.99),"$1500","$1000")

What I am looking for is if greater than 150 - "$1500", if between 120 &149.99 "$1000". if between 95 and 119.99 "$500" and if <94.99"$0"

can anyone help please?

Hi! The answer to your question can be found in this article: Nested IF in Excel – formula with multiple conditions. Read Example 1.

Hi Any help on this...

I need to calculate a number between the range of 2 numbers and I need to return 50% of the above value of whatever number has been input.

i.e. Between 60,000 and 100,000 I need to return 50% of whatever number is input..... so if they input 75,000 the answer needs to be 7500 which is 50% of the value of 75000 minus 60000 = 15000 = ANSWER 7500

Any ideas?

Hi! If you have two conditions, use an IF AND expression as described in these instructions: Excel IF: greater than AND less than. I also recommend that you read the first paragraph of the article above carefully. Your description of the calculations in the second paragraph contradicts the first paragraph. But I think you can write the calculation formula yourself.

I've tried IF, AND, MATCH, XMATCH, and I can't seem to get my formula to work. In one sheet I have Move Out Date & Fiscal Year. In another sheet, I have the dates of the fiscal year (start & end) and the Fiscal Year name.

Move Out Date Fiscal Year

09/01/2011

09/05/2011

09/10/2011

Start End Fiscal Year

9/1/2011 8/31/2012 FY2012

9/1/2012 8/31/2013 FY2013

9/1/2013 8/31/2014 FY2014

Depending on the date in the Move out Date cell, I would like for it to determine what the Fiscal Year is for that move out date. In other words, if column a, cell 1 is dated 9/1/2011, I want it to return "FY2012" into a column. Can anyone help me? Thank you.

Hi! To find Fiscal Year by two conditions, use the INDEX MATCH functions and these instructions: Excel INDEX MATCH with multiple criteria - formula examples.

I believe the following formula will help you solve your task:

=INDEX(Sheet2!C1:C10,MATCH(1,(Sheet2!A1:A10<Sheet1!A1)*(Sheet2!B1:B10>Sheet1!A1),0))

Hi! Need your help please to get the data I want using the compound "If" function to get the vacation leave balance based on the hiring data.

Below are the details:

A1: Hiring Date

Conditions:

* If hired between 1/1/2023 - 6/30/2023 = vacation leave should be 11 days

* If hired between 7/1/2023 - 7/31/2023 = vacation leave should be 6 days

* If hired between 8/1/2023 - 8/31/2023 = vacation leave should be 5 days

* If hired between 9/1/2023 - 9/30/2023 = vacation leave should be 4 days

* If hired between 10/1/2023 - 10/31/2023 = vacation leave should be 3 days

* If hired between 11/1/2023 - 11/30/2023 = vacation leave should be 2 days

* If hired between 12/1/2023 - 12/31/2023 = vacation leave should be 1 day

Really appreciate if you can help me build a formula based on the above. Thanks in advance!

Hi! I recommend reading this guide: Excel Nested IF statement: examples, best practices and alternatives. Try to use CHOOSE function instead of nested IF formula:

=CHOOSE(MONTH(A1),11,10,9,8,7,6,5,4,3,2,1)

Define the month number using the MONTH function.

if A1 gives current date and B1 says W then what is if formulae to show the actual date seen in A1 (not update it).

Hi! Based on your description, it is hard to completely understand your task. However, I’ll try to guess and offer you the following guide: How to insert today date & current time as unchangeable time stamp.

sorry it was not clear, i'll try again as your solution didn't give me the result i needed. thank you anyway

A1 IS POPULATED WITH A DATE..... B1 IS EITHER D or W...... C1 needs to give the result.

so what is the formula to be put into C! if B2 is W ....to replicate the date seen in A1. (it needs to be the same date that is there and not update it

Hi! Your description of the problem is not very clear. I will try to assume such a formula for cell C1:

=IF(B2="w",A1,"")

This will work if the date in A1 is written manually. If the date in A1 is entered using the TODAY function, use the method I recommended earlier.

thank you so much, that's worked a treat. Thank you for your patience too.

sorry for the lack of clarity.

Hi and thank you in advance,

I'm trying to automate functional lab evaluations. So far, I've been able to use a nested conditional formatting:

=IF(N7>=7.5,"Acute infection",IF(N7<=5,"Chronic infection"))

The problem I'm having is that when a result is functionally in range it returns the word FALSE. I don't want anything to appear in a cell where the lab result is in the functional range (I have to build this because the functional range is much tighter than the reference range printed on the lab report--it just takes a lot of time to evaluate).

How do I prevent the word FALSE and just show a blank cell. Otherwise my report looks extremely cluttered and is hard to go over with patients.

Appreciate it!

Hi! Read the IF function manual carefully. Define value_if_false argument.

=IF(N7>=7.5,"Acute infection",IF(N7<=5,"Chronic infection",""))

Hi there, looking to extract data during a one month period (eg. May 30 - June 30) across a 30 year period in one set of data. Is there a way to do this without having to repeat a formula 30 times?

Thanks.

Hi! Use the DAY and MONTH functions to specify the desired dates. For example:

=AND(DATE(2023,MONTH(A1),DAY(A1))>=DATE(2023,5,30),DATE(2023,MONTH(A1),DAY(A1))<=DATE(2023,6,30))

Hello! I need help with a formula.

Columns are:

Column I - End Date: 5/31/2023

Column M - Sign On Payout: 7/30/2023

Column K - Amount: 1000

I was hoping to write a formula that says if the end date is before or equal to the payout date then "N/A", if not the amount.

=IF(AND(I5>=M5,I5<=M5),"n/a",K5) is what I wrote and its not working.

thanks

Hi! Remove the AND condition from the formula

=IF(I5<=M5,"n/a",K5)

I did this and its still not working. I even tried formatting the cells for the dates to be the same. Any advice?

Thank you

Hi! The formula matches your question. Check your data. I also recommend studying the article above carefully.

Hi,

I need excel formula for below example.

Sheet 1

Date Part Code Qty Rate

10-01-2023 ABC 10 25 Rate should be come through formula from "sheet 2" - First match "part code" & Date match with "sheet 2" between date

12-01-2023 ABC 20 30

11-01-2023 XYZ 5 12

Sheet 2

Part Code Valid from Valid To Rate

ABC 01-01-2023 05-01-2023 20

ABC 06-01-2023 10-01-2023 25

ABC 11-01-2023 15-01-2023 30

XYZ 01-01-2023 10-01-2023 10

XYZ 10-01-2023 12-01-2023 12

Thanks!

Hi! If I understand your task correctly, this article may be helpful: Excel INDEX MATCH with multiple criteria. Try this formula:

=INDEX(Sheet2!D2:D6,MATCH(1,(Sheet1!A1>=Sheet2!B2:B6)*(Sheet1!A1<=Sheet2!C2:C6)*(Sheet1!B1=Sheet2!A2:A6),0))

Hi, I'm trying to pull through certain data from a sheet based on a name if the dates in column B on that sheet falls between a certain month only.

=IF(('PC 156598'!B:B>=DATEVALUE("11/1/2023"),'PC 156598!'B:B<=DATEVALUE("11/30/2023")),VLOOKUP(C2,'PC 156598'!$A$2:$C$64,3,0),0)

Excel is saying there's something wrong with the second tab reference 'PC 156598!' Have I nested a vlookup within the IF formula incorrectly?

Please help! Thank you

Hi! I can assume that you wanted to use an IF formula with two conditions. However, you do not have an AND or OR operator to combine the conditions. For example,

=IF(AND('PC 156598'!B:B>=DATEVALUE("11/1/2023"),'PC 156598!'B:B<=DATEVALUE("11/30/2023")),VLOOKUP(C2,'PC 156598'!$A$2:$C$64,3,0),0)

For more information, please visit: Excel IF function with multiple conditions.