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:
To include the boundary values, use the greater than or equal to (>=) and less than or equal to (<=) operators:
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:
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 between 10 and 20, including the boundaries: 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: Including the boundaries: 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: Including the boundaries: 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. 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: 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: Including boundaries: To return your own values instead of TRUE and FALSE, use the following Excel IF statement between two numbers: OrIf between two numbers then
=IF(AND(A2>10, A2<20), "Yes", "No")
=IF(AND(A2>=10, A2<=20), "Yes", "No")
=IF(AND(A2>B2, A2<C2), "Yes", "No")
=IF(AND(A2>=B2, A2<=C2), "Yes", "No")
=IF(AND(A2>10, A2<20), A2, "Invalid")
=IF(AND(A2>=10, A2<=20), A2, "Invalid")
If boundary values are in different columns
=AND(A2>MIN(B2, C2), A2<MAX(B2, C2))
=AND(A2>=MIN(B2, C2), A2<=MAX(B2, C2))
=IF(AND(A2>MIN(B2, C2), A2<MAX(B2, C2)), "Yes", "No")
=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:
Not including the boundary dates:
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:
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:
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)
158 comments
I would like a hand with the following calculation if possible?
Low High Multiply Options Quantity Result
1 23 6 Option 1 15
24 42 17 Option 2 8
43 63 33
63 999 38
I have managed the following calculations so far, but would like additional IF's in the equation:
=IF(AND(SUM(Option 1 Quantity: Option 2 Quantity)>=Low 1,SUM(Option 1 Quantity: Option 2 Quantity)<=High 23),Option 1 Quantity*Multiply 6)
Options 1 and 2 will fluctuate, based on that I would like additional IF statements for increase Low High betweens.
Please let me know if you have questions about this.
Hi! If I understand your task correctly, the following tutorial should help: Nested IF in Excel – formula with multiple conditions.
Hello Sir Alexander Trifutov
please help me i want to classify Growth Number to this "GROWTH BELONGING"
GROWTH GROWTH BELONGING
96% 76% - 100%
66% 51% - 75%
44 26% - 50%
30 26% - 50%
10 1% - 25%
-20% -25% - 0%
-46% -50% - -26%
-66% -75% - -51%
-91% -100% - -76%
WHAT FUNCTION SO TO BE RESULTING THIS "GROWTH BELONGING" , THANKYOU SIR
Hi! Look for the example formulas here: Nested IF in Excel – formula with multiple conditions.
Hi, i need a formula that can give me the result (Region), if the value in code1 is my search, and range is between code2 and code3 and result is Region
code1 Code2 Code3 Region
2552 2492 2493 Lower Austria
2564 2500 2899 Lower Austria
2822 3000 3329 Lower Austria
2822 3331 3333 Lower Austria
2822 3340 3999 Lower Austria
3125 4000 4299 Lower Austria
3133 4300 4309 Lower Austria
3133 4392 4392 Lower Austria
3133 4430 4439 Lower Austria
3133 4441 4441 Lower Austria
3133 4482 4482 Lower Austria
3161 5000 5119 Salzburg
3161 5150 5169 Salzburg
3264 5200 5209 Salzburg
3264 5300 5309 Salzburg
3264 5320 5330 Salzburg
3321 5340 5340 Salzburg
3830 5342 5342 Salzburg
3841 5350 5359 Salzburg
thanks
Hello Ema!
We have a special tutorial that can help to solve your problem: Excel INDEX MATCH with multiple criteria - formula examples. The formula below will do the trick for you:
=INDEX(D2:D15,MATCH(1,(B2:B15<A2:A15)*(C2:C15>A2:A15),0))
Hello dear Alexander!
that was really quick reply. Thank you.
The formula works for many of the lines, but for some is giving wrong results.
i adjust it as =INDEX(BB:BB,MATCH(1,(AZ:AZAZ:AZ),0)), where BB is my region, AZ is code2; F4 is my search(code1); and BA is my code3.
but for example
if i search number 2000, should give me result Lower Austria, but result is Vienna
2000 2419 Lower Austria
1000 1999 Vienna
Can you please support me further?
Hi! Your written formula is not shown in full. However, I can assume that you will need to add a = to the formula. Also, I do not recommend using the entire column reference in the formula. This can slow down the calculations considerably.
=INDEX(D2:D15,MATCH(1,(B2:B15<=A2:A15)*(C2:C15>=A2:A15),0))
Hi Alexander,
I've changed the formula as you've mention above, but still facing issues.
I want to share a screen shot but i am not able to so i am sharing the table.
A B C D
Range 1 Range 2 Region Search code
2420 2429 Burgenland 6020
2473 2475 Burgenland 9132
2491 2491 Burgenland 9020
7000 7399 Burgenland 1190
7400 7419 Burgenland 1040
7422 7423 Burgenland 8010
7430 7479 Burgenland 4063
7500 7599 Burgenland 1110
8380 8389 Burgenland 2442
9000 9319 Carinthia 9512
9321 9322 Carinthia 2103
9400 9699 Carinthia 9500
9700 9779 Carinthia 2472
9781 9781 Carinthia 1090
9800 9899 Carinthia 3430
2000 2419 Lower Austria 1220
2430 2469 Lower Austria 5020
2471 2472 Lower Austria 1180
2480 2489 Lower Austria 4400
2490 2490 Lower Austria 8010
2492 2493 Lower Austria 4942
2500 2899 Lower Austria 1210
3000 3329 Lower Austria 1120
3331 3333 Lower Austria 1210
3340 3999 Lower Austria 4810
4000 4299 Lower Austria 1100
4300 4309 Lower Austria 1100
4392 4392 Lower Austria 8020
4430 4439 Lower Austria 4060
4441 4441 Lower Austria 2514
4482 4482 Lower Austria 1110
5000 5119 Salzburg 8010
5150 5169 Salzburg 8081
5200 5209 Salzburg 1050
5300 5309 Salzburg 9900
5320 5330 Salzburg 9853
5340 5340 Salzburg 2482
5342 5342 Salzburg 1100
5350 5359 Salzburg 1100
5400 5799 Salzburg 8054
7421 7421 Styria 1100
8000 8369 Styria 6130
8400 8999 Styria 8010
9323 9323 Styria 6020
9330 9379 Styria 1230
6000 6699 Tyrol 1210
9782 9782 Tyrol 4020
9900 9999 Tyrol 4020
3334 3335 Upper Austria 4061
4310 4389 Upper Austria 1210
4391 4391 Upper Austria 2540
4400 4429 Upper Austria 5230
4442 4443 Upper Austria 1020
4450 4479 Upper Austria 2522
4481 4481 Upper Austria 9020
4483 4444 Upper Austria 9181
4490 4499 Upper Austria 1120
4500 4999 Upper Austria 3100
5120 5149 Upper Austria 4600
5210 5289 Upper Austria 2380
5310 5319 Upper Austria 4040
5360 5369 Upper Austria 4550
1000 1999 Vienna 4030
6700 6999 Vorarlberg 1150
Hi! The data you are now using is different to the data you described in the first question. Try this formula for these data:
=INDEX($C$2:$C$65, MATCH(1,($A$2:$A$65<=D2)*($B$2:$B$65>=D2),0))
Hi Good day!
I need excel formula for below example.
BILLING DATE ,DISCONNECTIONDATE, SUSPENSIONDATE, REACTIVATIONDATE
A.FULLY ACTIVATED
B.NO REACTIVATION AFTER DISCONNECTION (before billing date)
C.NO REACTIVATION AFTER SUSPENSION (before billing date)
D.DISCONNECTED/SUSPENDED BUT REACTIVATED (reactivation occurred before billing date)
E.SUSPENDED BEFORE BD BUT REACTIVATED (AFTER Billing date)
F.DISCONNECTED or SUSPENDED (AFTER billing date)
G.ACTIVATED DURING CURRENT MONTH
Hi! Sorry, it's not quite clear what you are trying to achieve. Have you tried the methods described in this blog post? If you are not satisfied, please let me know and I will try to help you.
I am working with a large amount of financial data and trying to separate into Financial Statement type by GL#. I have entered the following formula:
IF((G2400000,G2500000, "Expenses")))
Balance sheet accounts GL# is less than 500000, Revenues are in the 400000 range, and expenses in the 500000. Excel is telling me this is an invalid formula. What am I doing wrong here?
Hi! Based on your description, it is hard to completely understand your task. I can assume that you have two conditions. So try using the IF AND formula. Look for the example formulas here: IF AND in Excel: nested formula, multiple statements, and more. If this does not help, explain the problem in detail.
Hi Alex,
What formula should I use if I want to check
If my Renewal End Date :4/27/2024 and close date is 4/4/2024 & I want to check if close date is less than or equal to renewal end date ?
Hi! Have you tried any of the methods described in this blog post? You can also use these instructions to compare two dates and display the desired message: Using IF function with dates. Simply compare the two cells and determine which one is larger.
How do i check if a cell is between two dates, and return one of three values.
I.E
Does A2 have a date between 01/01/2024 - 31/01/2024.
If yes, return Yes.
If no, return no.
If A2 has nothing in the cell, return as blank.
Hi! Have you tried the methods described in this blog post? The formula might look like this:
=IF(A2<>"",IF(AND(A2>D1, A2<D2), "Yes", "No"),"")
Read more: Nested IF in Excel – formula with multiple conditions.
Hi Alexander, thank you! I was trying that for hours, and yes i had read the blog post. I look at Excel formulas maybe one every 9/10 months, so i just don't hold the information very well!
It's really apprecaited.
Hi,
I would like to use IF function to calculate the age to a certain date and turn Yes the result is >=16 or No if it is <16. How can I dothat?
Hi! The following tutorial should help: How to calculate age in Excel from birthday. Calculate the age and use it in the IF formula as described in the article above.
=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?
Hi! "2/19/2024" may not match your computer's date format. Also, note in the article above that you should use the AND operator, not the OR operator, for the date range. You can also try to set the date by using the DATE function. For example:
=IF(AND(C3>=DATE(2024,2,19), C3<=DATE(2024,2,25)),K3, 0)
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))