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:
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.
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:
=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:
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)
83 comments
One Column contains date and another Column contains Serial nos. but in this Sr. no. Columns there is blank Space which need not to pick while seeing date column .
We have to count total no. of dates wrt to Sr. nos.( Blank space of sr. no. not to be counted) .
Hi! You can count number of values by condition using COUNTIF function. Look for the example formulas here: COUNTIF function in Excel - count if not blank, greater than, duplicate or unique. I can't offer you formula as I don't really understand exactly what dates you want to count.
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.
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.
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.
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))
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.
Trying to figure out how to produce this (not working)sheet has 2 tabs =IF column H matches column E (Names Match) on other tab (tab name) then check column D (Renewal Date) if less than or greater than date in column I5 (Jan-24) than produce column N Price or column O price
Hi! I recommend reading this guide: Excel nested IF statement - multiple conditions in a single formula. To correctly reference to other worksheets, I recommend studying: Excel reference to another sheet or workbook (external reference).
Hi Alex ,
thank you very much for your time , can you please help me with my formula please , all what I need to show is meet, not meet & (Blank if there is no date i the K columns) I did the Meet & not Meet formula but I just can't get the cell to be blank if there is no date entered , can you help me please , this is the formula I'm using =IF(K5>H5,"Meet",IF(K5<=I5,"Not Meet", I tried the IFBLANK ,"" , but nothing is working , what I need , when I enter date in K, column L will shoe me If meet and didn't meet (WORDs) the due date in (I) , but if there is no date in K I want L to be Blank,, can you help me please ..Thank you
H I J K L
Dyployment Date Lodgement due date Reminings days from today loedgment date Deadline were meet?
1/09/2023 6/09/2023 13 4/09/2023 Meet
Hi! If I understand your task correctly, use the ISBLANK function to check if cell is blank:
=IF(ISBLANK(K5),"",IF(K5>H5,"Meet",IF(K5<=I5,"Not Meet")))
Hi Alexander,
I hope you can help me with the following problem I've encountered on excel. For explanation purposes, i'll use example cell R5 as a reference
I'm creating a list (in rows) that uses one column (column Q) where I enter completion dates and in the next column (column R), excel auto-calculates the next due-dates by using the following formula R5=date(year(Q5)+2,month(Q5),day(Q5)) - if the due date is in 2 years, for example). This works perfectly and I could combine the calculated due date (say in cell R5) with conditional formatting to highlight when the future dates are coming close.
As a follow on, I want Excel to auto-calculate how many of the rows in column R (future due-dates) are still within date and how many have expired to find out the overall compliance percentage. By adding in a third column and using an the formula =If(R5>=today(),"1","0") i wanted to assign numerical values to dates that have not yet come to pass and then have excel calculate the compliance based on the numerical value of 1, but in %. However, between the dates and numerical values, my Excel does not seem able to do this. Could you help me out on the formula please?
Thank you so much in advance.
KR, Stef
Hi! You can use the COUNTIF function to calculate values by condition. Read more: COUNTIF formulas for dates. For example,
=COUNTIF(R5:R10,"<"&TODAY())
Hi all,
I need to schedule an outage and I want to choose a date that affects the least amount of schools while their testing is on. So, how can I see the best date? If choose the 14 August how many schools (and which if possible) have testing on that date? What if I choose 15 August, how many would that effect?
I have over 6000 rows to look at so any formula tips would be much appreciated! :)
School Name State Testing Startes Testing Finishes
School 1 Victoria 01-Aug-23 12-Sep-23
School 2 Queensland 10-Aug-23 31-Aug-23
School 3 Victoria 15-Aug-23 30-Aug-23
School 4 Queensland 28-Aug-23 31-Aug-23
School 5 New South Wales 28-Aug-23 8-Sep-23
You can count the number of values for a specific date using the COUNTIF function. For example:
=COUNTIF(B2:B10,DATE(2023,8,14))
Read more: Using Excel COUNTIF function with dates.
You can get a list of values that correspond to a specific date by using the FILTER function:
=FILTER(A2:A10,B2:B10=DATE(2023,8,14))
Look for the example formulas here: Excel FILTER function - dynamic filtering with formulas.
You can do this without formulas by using Filter Tool and Find Cells Tool. It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.
If cell G8 is less than 200,000.00 then on cell H8, I'd like it to say NO LEVEL.
If cell G8 falls between 200,000.00 and 350,000.00, then on cell H8, I'd like it to say SILVER.
If cell G8 falls between 350,000.00 and 500,000.00, then on cell H8, I'd like it to say GOLD.
If cell G8 falls between 625,000.00 and 1,000,000.00, then on cell H8, I'd like it to say PLATINUM.
If cell G8 falls between 1,000,000.00 and 2,000,000.00, then on cell H8, I'd like it to say DIAMOND.
Can all these arguments go in one cell?
Hi! For multiple conditions, use the IFS function instead of IF. For example:
=IFS(G8<200000,"No", AND(G8>200000,G8<350000),"Silver")
hi guys can you help me solve this,
the condition is
if the sum is 0-15 the percentage must be 50% in Cash and 50% in Installment,
if the sum is 16-25 the percentage must be 40% in Cash and 60% in Installment ,
if the sum is 26-40 the percentage must be 30% in cash and 70% in installment
and if the installment reach the percentage the column shows "PASS"
Hi! Look for the example formulas here: Nested IF in Excel – formula with multiple conditions.
Hi I tried using the if function but am really struggling
basically what i want to check is, if the date in f.e C9 is less than the current date today then it should say "expire" whereas if the date is C9 is higher than the date today it must say Active and also I want this to update itself so i dont have to go back everyday to update it
Any assistance would be awesome.
Hi! To compare a date with the current date, use the TODAY() function. See an example in article above and in this guide: Using IF function with dates.
Hi I am struggling to correctly write a formula with multiple if Conditions. I need it to check column E3 to see if it says "Invoiced". If this is true, it looks at Column/Cell D3 to determine if the Due date of the invoice is between a certain range of dates. If this condition is also true, it will return the value listed in B3. If it is false, it will leave the cell blank. This formula is not working -
=iferror(E3="Invoiced",(and(D3>=Datevalue("06/15/23"),D3<=Datevalue("06/30/23"),B3,"")))
Thank you!
Hi! The formula below will do the trick for you:
=IF(E3="Invoiced",IF(AND(D3>=DATEVALUE("06/15/23"),D3<=DATEVALUE("06/30/23")),B3,""))
For more information, please visit: Nested IF in Excel – formula with multiple conditions.
I can not thank you enough!
Hi,
I have a problem with a formula concerning dates...
=IF(C9<$M$6;"Due";"Not Due")
Where C9 is the due date of a invoice & M6 is the date where the breaking point if we will pay now or later. It works fine most of times but now I have a problem when the due date is in year 2022. Our breaking point (M6) is set to 6/30/2023 and with that all invoices with due date in 2022 (collum C) should show "Due". Some in 2022 does and some not, for example due date 12/16/2022, 10/31/2022 show "Due" correctly, but due dates 9/30/2022 & 8/31/2022 shows "not due" but it should show "Due". Can you see something wrong?
P.s. We need to have the breaking point (M6) as a cell and not in the formula since this is a template and we only want to change the cell M6 and not the formula every time our breakpoint changes.
Hello! If I understand your task correctly, the following tutorial should help: Excel INDEX MATCH MATCH and other formulas for two-way lookup. For example:
=INDEX(Sheet1!B2:F6, MATCH(A2, Sheet1!A2:A6, 0), MATCH(B1,Sheet1!B1:F1, 0))+INDEX(Sheet2!B2:F6, MATCH(A2, Sheet2!A2:A6, 0), MATCH(B1,Sheet2!B1:F1, 0))
I hope my advice will help you solve your task.
Hi,
I'm trying to use the IFS function to calculate the corresponding date the following calendar month i.e. 7/7/2023 will return 7/8/2023, but 31, and if the following calendar month has less days the end of the month will be returned i.e. 31/1/2024 will return 29/02/2024.
The IFS works great when only asked to consider the days of the month which extend over the end of the next month (the end of Jan and all the months with 31 says - except July and December). However, to include all the dates where 30 days need to be added individually (if the false value adds 31 days) and I'm running out of characters to be able to entre my formula.
Am I making thinks difficult for myself or is there a simple method which I have not been able to find?
Hi! Use the EOMONTH function to determine the last day of the next month. Then use the YEAR, MONTH and DAY function to find the date of the next month.
Try this formula:
=DATE(YEAR(EOMONTH(A1,1)), MONTH(EOMONTH(A1,1)), MIN(DAY(EOMONTH(A1,1)),DAY(A1)))
Good morning,
i am try to make this formula correct Im just not sure if i have the correct order It answers " false" every time I try and alter.
=IF(AND(F138=250,F129=24),IF(AND(F138>=300,F129=32),IF(AND(F138>150,F138<250),18,0),0)))
can someone help please.
Thanks in advance
Hi! I don't know what result you want to get. Your formula contains logical contradictions. If the first condition F138=250 is true, then after that the second condition F138>=300 can never be true. And if the condition F129=24 is true, then it can never be F129=32. Therefore the formula will always return FALSE.