IF is one of the most popular and useful functions in Excel. Generally, you use an IF statement to test a condition and to return one value if the condition is met, and another value if the condition is not met. Continue reading
by Svetlana Cheusheva, updated on
IF is one of the most popular and useful functions in Excel. Generally, you use an IF statement to test a condition and to return one value if the condition is met, and another value if the condition is not met. Continue reading
Comments page 23. Total comments: 2999
Hello,
I am trying to design a new spreadsheet as below
22/05/2015 05/06/2015
07/05/2015 07/05/2015 21/05/2015
Basically I want cell c to add 7 days to cell a if there is not date in cell b. If there is a day in cell b I want it to add 7 days to the date in cell b
Hi John,
The formula can be as simple as:
=IF(B1="", A1+7, B1+7)
Just remember to apply the Date format to column C.
Hi,
please help me to solve my problem. see formula below
IF(S64"closed",R$1-S64)
R1 value July 13 2015
S64 value July 13 2015
so the answer is zero but it shows false
i need zero answer
Hi Kyra,
You have the same cell reference S64 both in the logical test and value_if_true. It simply cannot be "closed" and "July 13 2015" at the same time :)
Hi,
I am needing a formulae to highlight the cells if the date entered is within a week from the current date. How can I do this?
Hi Iona,
Do you want to highlight dates that are +- 7 days from the current day, or those that are within the current week?
I would like it to highlight dates that +7 days or less from the current.
Iona,
You can create a conditional formatting rule with the following formula:
=ABS(TODAY()-$A2)<=7
Where A2 is the top-most cell with a date.
That's great thanks. How do I change the words 'TRUE' and 'FALSE'.
The formula returns TRUE and FALSE when you enter it in a cell. If you create a conditional formatting rule with this formula, it will highlight the cells that meet the condition. For the detailed steps to create a rule, please see the link in my previous reply.
If you want the formula to return some other words, enclose it in the IF function, for example:
=IF(ABS(TODAY()-A2)<=7, "recent date", "older date")
Works perfectly, thanks.
7/10/2015 6/10/2015 In this cell i want the Latest one.
6/10/2015 7/10/2015 In this cell i want the Latest one.
How could it Possible.
Hi Suvendu,
Supposing that the dates are in columns A and B, you can use the following MAX formula:
=MAX(A1:B1)
I am trying to use a IF/Find or IF/Search expression to locate the total expense associated with a particular budget name. I want to search an entire worksheet for a particular name "Total 81320 Communications" which may be in column c or d of the worksheet - and then report the value found in column x from that same row as the name.
Is this the correct way to build a formula - with the IF(ISNUMBER (SEARCH"text",worksheet A1:V100)
Hi NANCY,
Yes, it's the correct approach. Here's a real-life formula example:
=IF(ISNUMBER(SEARCH("deliv",C2)), "No", "Yes")
You can view the result the formula returns in "Example 3. IF formula for text values with partial match".
Hi, In Sheet1, I have 2 columns i.e. Company_Name and Credit_Period(No.of Days). In Sheet2 the company name appears in several rows and in the adjacent cell, I want it to pick-up the credit period (as mentioned in Sheet1). Can you guide for a formula please.
Thanks in advance for your help.
Upon further research on your website, I found the requried formula https://www.ablebits.com/office-addins-blog/excel-index-match-function-vlookup/
Superb. Thanks a lot.
Hi Svetlana,
How can i condition +- in excel, i got a value lets say 15 +-0.5 how can i arrange that in a excel formula, if the value is +0.5 fail also if it is -0.5
Many thanks for any help you could give me
Hi Charles,
You can use a formula similar to this:
=IF(OR(A1>15+0.5, A1<15-0.5),"fail", "pass")
I need a formula where it sum the amount of column B if the date in column A is between the dates in columns C and D.
The date in column A should be greater than the date in column C and less than the date in column D.
Hello Mili,
You can use an array formula similar to this:
=SUM(IF((B2:B9>C2:C9) * (B2:B9<D2:D9), A2:A9,""))
Remember to press Ctrl+Shift+Enter to enter it correctly.
Hi there,
Wondering if anyone could help me. I need a formula where it searches in a column for a particular word, then it shows a particular cell.
If(A:A,"WOR",C5)
Is this possible? Many many thanks,
Yuko
Hi Yuko,
You need to write a formula for one cell, and then you can copy it to as many cells as you want or across the entire column:
=If(A1="WOR",$C$5, "")
Could you tell me what is wrong with this formula
=IF(R3<=24,24-Q3,R3=0)
The value_if_false argument. You cannot use R3=0 because the formula can return a value only in the cell in which it is entered.
Hi,
can someone help me answer the below;
I would like to search, for example, "major" or "minor" in C1, if C1 contains either major or minor, i want to return "True".
table below;
C1= major minor young old , return "True"
C1= major young, return True
C1= minor old, return True
C1= young old, return False.
Much appreciate for your help.
Regards,
Hi Bravo,
Here you go:
=IF(OR(ISNUMBER(SEARCH("minor",C1)), ISNUMBER(SEARCH("major",C1))),TRUE, FALSE)
Svetlana
I have a cell with text such as TX,EP. If TX appears it should
be mutiplied by 5%. I tried the following but it does not seem to
work
=IF(AF2739= "TX", AF2739*0.06,)
Need your help to point out whether this is the correct manner
of doing it. Thanks
Sorry should be AG2739*.06
H Thong,
You probably meant "multiplied by 6%". If so, the formula =IF(AF2739="TX", AG2739*0.06,) is correct.
Svetlana
Thanks
Hi,
I'm using an IF formula which is designed to look at a data tab and find a match for a number in one column and return the corresponding values from another column. This is working well expect one of the numbers, 3370, is also returning the values attached to 333700 and 533700. How do I ensure that the values returned are just for an EXACT match and not numbers which include 3370??
Hope you can help!
Hi Tim,
It's hard to say anything with certainty without seeing your data. Probably you can use a VLOOKUP formula with exact match, as demonstrated in:
https://www.ablebits.com/office-addins-blog/excel-vlookup-tutorial/#exact-approximate-vlookup
I will say again that for some reason greater than and less than symbols won't show
Hi Hardwareman,
Our blog engine cuts off greater than and less than symbols quote often, sorry for that. I think you can use a nested IF formula like this:
=IF(T11<>"","", IF(R11<>"",F11,""))
Hi,
I want to make a cell turn blue if I enter a date or red if I enter text.
I cant figure this out....searched everywhere for info.
Thanks,
Jack
Hi JACK,
You can create the conditional formatting rules, with the following formulas:
Blue: =ISNUMBER($A2)
Red: =ISTEXT($A2)
Where A1 is the top-most cell with data in the column, not including the header.
I have a name in column A. Depending on what it is, column B should have another name. For example. A says "Alaska" B would say "West" or if A said "New York" B would say "Eastern", etc. Can't make it work. Thanks for your help.
Hi Paula,
What you need is a nested IF formula like this:
=IF(A1="Alaska", "West", IF(A1="New York", "Eastern", ""))
Hi there.
I'm trying to create an IF statement that will return nothing if there is nothing in the cell adjacent, but if there is anything text or number in that cell, then it will perform a formula.
Example
A1 Says, "Hello" then B1 will perform (B1*B6)
I can get an IF statement to result in nothing if A1 is blank, but I can't figure the right way to have it do a formula if there is something in A1.
Hi George,
Simply put the calculation in the value_if_false argument. For example,
=IF(A1="", "", B1*B6)
Can IF function for dates be used in a library system?
I want that the book I've borrowed is in its due date, the date would turn to red or there will be notification that it's already due.
Hi Ruben,
You can use an IF formula to display a notification, for example:
=IF(A1<=TODAY(),"Due", "")
It will display "Due" is the Due date in A1 is equal to to less than today's date.
To highlight dues dates in some color, please see How to conditionally format dates and time in Excel.
Hi Svetlana, I need help with a formula. I need to compare E1(total sale) to F1(goal)and display 10% of E1(total sale) if the store made or surpassed its F1(goal) and 0 if it did not make its goal.
Hi Sharee,
Here you go:
=IF(E1>=F1, E1*0.1, 0)
hi Svetlana, thnx for your help but i need it again. please guide me to make this farmula.
A1="UA" i want cell A1 to be color in red
how it will work?
like if i put the word UA in A1 i want A1 to be filled with Red color otherwise if i put anything else it stays normal
Hi Sharfi,
Simply create a conditional formatting rule with this formula:
=$A1="UA"
hi Svetlana, thnx for your help but i need it again. please guide me to make this farmula.
A1="UA" i want cell A1 to be color in red
how it will work?
Hi Sharfi,
You can do this by creating a conditional formatting rule with the formula =$A1="UA"
I want to know the formula as per following data:
F G H
1 50 100 (I want if G1 value is less than 100 so F1 multiply with 10 but if G1 value is greater than 100 and less than 200 so F1 multiply with 20 and if G1 value is greater than 200 so F1 multiply with 30 and answer came in H1)
kindly provide assistance
Hi Adeel,
Here's the formula for H1:
=IF(G1<100, F1*10, IF(G1<200, F1*20, F1*30))
Hi Svetlana Cheusheva,
am just looking to put one formuls to calculate the tax value using IF function.the things are like follows....
Suppose if there three columns f j and h
if i enter the value in f as 5.5% then it should give me the value of the f*h in the column j
ex: (in column j) =IFf=5.5% then it should calculate the value of f*h.
could you plese help me out in this...
Hi KIRAN,
If you need a formula exactly for 5.5%, then enter the following one in cell J2:
=IF(F2=5.5%, F2*H2, "")
The above formula multiplies F2 by H2 if F2=5.5%, and returns an empty string otherwise.
If you are looking for a more universal formula that multiplies a value in column H by whatever percentage you enter in column F in the same row, then use this one:
=IF(F2<>"", F2*H2, "")
Hi Svetland,
Please help me write this IF formula correctly. i have a cell with different figures but some are missing data sets.
i want a command that says IF F3>1 then the answer should be 1, IF F3<1 then it should be 0 but if F3 is empty (meaning there is no number there) it should be empty. meaning if F3 is empty, leave blank.
Kindly assist.
thank you
Hi NASCO,
You can use a nested IF formula like this:
=IF(F3>1, 1, IF(F3<1, 0, ""))
Please pay attention that the formula will also return an empty string if F3=1. So, you may probably want to add one more condition to the formula or replace F3>1 with F3>=1.
What if I want more than one logical test in my formula?
eg: If I want "IN TRANSIT" and "DISPATCHED" to be covered by one formula only.
Awaiting Response
Hi Aditya,
You can do this by using nested IF functions, for example:
=IF(A1="IN TRANSIT", value_if_true, IF(A1="DISPATCHED", value_if_true, [value_if_false]))
Thank you so much. you were a great help.
Hi Svetlana,
Can you please resolve the issue with my formula. I am trying to enter multiple logics with multiple values.
=IF(D1>22,"This is a VERY HIGH risk study"), IF(D1>17,"This is a HIGH risk study"), IF(D1>12," This is a MEDIUM risk study"), IF(D1<=12,"This is a LOW risk study")
Thanks
Hi Jamil,
When using nested IF's, all closing parentheses should be at the end of the formula, like this:
=IF(D1>22,"This is a VERY HIGH risk study", IF(D1>17,"This is a HIGH risk study", IF(D1>12," This is a MEDIUM risk study", IF(D1<=12,"This is a LOW risk study"))))
Thanks Svetlana, Works like a dream.
BW
J
Hi Svetlana,
i have this issue with my formula:
D1 : due date
E1 (value) : =NOW()-D1
F1 : open or closed
what i'm trying to do is, when i choose F1 as closed, i would like to have E1 value to be '0'. this is my formula which is still in error : =IF((NOW()-D1),(F1=Closed)),'0'.
please help,thanks in advanced!
i managed to find the error and fix the formula. Here is the fixed formula =IF(F1="Closed","0",NOW()-D1). =)
how can i right a formula if i want result of that cell is equal or less than zero to return zero value?
Thank you,
Tien
Hi Tien,
You can use a formula similar to this:
=IF(A1<=0, 0, "")
All I want is D33 to return 100 if B33 is Yes and 0 if B33 is No. So I tried =IF(B33="Yes",100,0) but I keep getting a #NAME error. What am I doing wrong?
Hello Cindy,
The formula is correct, given that B33 is always either "yes" or "no".
In Microsoft Excel, the #NAME error occurs when Excel cannot not recognize the function's name. Hardly someone can misspell IF's name, but maybe you are using a non-English localization of Office?
Good Day! Please help.
I'm trying to get a total of the amount of days used in a month in a numerical form (to be used for a running total formula). The days are either full days and half days used, but the input is in mixed form.
This is what I tired but it didn't work: =IF((OR(B5:AC5=F,"1",B5:AC5=0.5,".5"),SUM(AE5:AE5))
Thank you so much for your help.
Alaine
Hi Alaine,
I do not exactly understand your criteria, but you definitely need the SUMIF function, or more likely SUMIF + SUMIF to add up values with the OR logic. You can find an example here:
https://www.ablebits.com/office-addins-blog/excel-sumifs-multiple-criteria/#sumif-multiple-criteria
How do I calculate days using info in 2 separate columns but tell the formula to only calculate it using the column that has a value in it?
Hi Julianna,
Please explain how exactly you want to calculate dates. Simply pull a date from a column that has a date in it? And what if both columns have dates?
Why i can't write this?
=SUM(IF(AND(J1012),(M10-K10+(L10-J10)*60-60),IF(AND(J1016),M10-K10+(L10-J10)*60-15,M10-K10+(L10-J10)*60)),IF(AND(J1112),M11-K11+(L11-J11)*60-60,IF(AND(J1116),M11-K11+(L11-J11*)60-15,M11-K11+(L11-J11)*60)))
there have another two need to add up.
=SUM(IF(AND(J1012),(M10-K10+(L10-J10)*60-60),IF(AND(J1016),M10-K10+(L10-J10)*60-15,M10-K10+(L10-J10)*60)),IF(AND(J1112),M11-K11+(L11-J11)*60-60,IF(AND(J1116),M11-K11+(L11-J11*)60-15,M11-K11+(L11-J11)*60)))
=SUM(IF(AND(J1012),IF(AND(J1016)IF(AND(J1112)IF(AND(J1116),
IF(AND(J10 less than 13, L 10 more than 12), (J10 less than 17, L 10 more than 16)
J11, L11, same as above.
Hi!
I'm trying to find a formula that returns Yes or No if the cell format is a Date or text.Is there a formula that can identify if the cell is a date or text??
Example:
6/12/15 Yes
Complete No
Hi Dan,
Because Excel dates are numbers in their nature, you can use the ISNUMBER and ISTEXT functions to identify dates and text, respectively:
=IF(ISTEXT(A2), "No", IF(ISNUMBER(A2), "Yes"))
If there are numbers in your column as well and you want to skip them, the formula won't work properly. In this case, you may need a VBA function to identify valid dates:
https://www.mrexcel.com/forum/excel-questions/36619-there-%22isdate%22-type-function-excel.html
Thank you!! this is exactly what I was looking for.
Hello,
I am trying to see how many people made a gift last year that is less than this year, and the difference is greater than $500, then get the sum total of all those records. Any help is appreciated. Thank you!
=IF(O1=N1,"Yes","Difference noted of "&O1-N1>500)
Hi Patcha,
To output "yes" and "Difference noted of O1-N1>500" messages, you can use the following formula:
=IF(O1=N1,"Yes", IF(O1-N1>500, "Difference noted of O1-N1>500", ""))
To find the total of ">500" records, use the following array formula (remember to press Ctrl+Shift+Enter to complete it):
=SUM(--((O1:O100)-(N1:N100)>500)*1)
I would like to create an IF formula to calculate the following and can't seem to get it right. If Cell L71 is empty, leave it blank, if it is Y, put Can Be Deducted in Cell M71, if N, put Can Not Be Deducted in Cell M71.
I keep getting it to only say either Can Be Deducted, or Can Not Be Deducted, It wont do both for me. This is what I used =IF(ISBLANK(L71)=TRUE,"",IF(ISTEXT(L71="Y")=TRUE,"Can Be Deducted"=FALSE,"Can Not Be Deducted"))
Hi April,
I believe the formula for M71 could be a bit simpler:
=IF(ISBLANK(L71), "", IF(L71="y", "Can Be Deducted", IF(L71="n", "Can Not Be Deducted", "")))
Thank you so much!
Can u tell a formula for this, using if condition.. If grade is PP, credit point multiply to 1. If grade is CR, credit point multiply to 2. If grade is DN, credit point multiply to 3. If grade is HD, credit point multiply to 4.
grade credit quality points
PP 12 12*1
CR 12 12*2
DN 12 12*3
HD 12 12*4
Hi Ahmadh,
Supposing that your grades are in column A and credit points in column B, you can use the following nested IF functions:
=IF(A2="PP",B2*1,IF(A2="CR",B2*2,IF(A2="DN",B2*3,IF(A2="HD",B2*4,""))))
thank you so much!!
how about i need something less than 50 turn into yellow color word, less than 0 turn into red color word.
Is that possible?
Hi Richard,
You can do this by creating Excel conditional formatting rules with the following formulas:
Red: =$A2<0 (should be the 1st rule in the list)
Yellow: =$A2<50
Where A2 is the top-most cell with data.
Hi Svetlana,
Could you please help me on below ?
I have 5 supplier, SupplierA have 10 purchasing order (eg. PO#0001 - PO#0010), PO no. 0001 have split to 5 transactions with different amount.
How do i make a formula to find out total amount for each PO follow by each supplier ?
Thank you in advance for your kind advise.
Hi Josephine,
You can use a SUMIF formula similar to this:
=SUMIF(A2:A100, "SupplierA", B2:B100)
Where column A is the supplier name and column B is amounts to sum.
Hi there.
I would like to highlight a row based on a certain cell being a value greater than 0. ie. if cell H8>0 "Highlight row 8 (or a range of cells)
Hi Garth,
Simply select the rows you want to highlight and create a conditional formatting rule with the formula for your top-most row, e.g. =$H8>0
Hello Svetlana,
I am not sure if I am doing this correctly. I would like to check in a row in the columns A through D for the keyword "PLAN". If it is present the result would be "Yes" and if not present for the cell to remain blank. I tried this function but it does not work: =IF(ISNUMBER(SEARCH("PLAN",A2:d2)),"Yes","")
Thank you,
Matt
Hi Matt,
Try this one:
=IF(COUNTIF(A2:D2, "plant")>0, "yes", "")
Hi Svetlana,
Worked perfectly.
Thank you,
Matt
Hello, I would like to increase each numerical value by $100 in every cell in a very large table that has a number, but if there is text in the cell, then I would like to simply copy the text from the call. Can this be done with the IF function?
Hi Marlene,
You can use a formula similar to this:
=IF(ISNUMBER(A1)=TRUE, A1+100, A1)
HI! I HAVE TEXT INPUT FOR A2 TILL A100, EACH TEXT INPUT IS EQUIVALENT TO A NUMBER, EX, IN A3 (LC) AND IN B3 I PUT THE EQUIVENT IS 0.75 , IF I PUT A FREE TEXT IN C1 (LC) I NEED TO DISPLAY THE EQUIVALENT IN D1.
A B C D
1/ BS- 1 LC 0.75
2/ NC- 1.75
3/ LC- 0.75
4/ WL- 0.50
EX ABOVE : I INPUT LC IN C1 , I NEED TO DISPLAY THE EQUIVALENT WHICH IS 0.75 IN D1 ( WHICH IS FROM B4) I WANT IT TO DISPLAY AUTOMATIC ONCE I PUT ANYTHING FROM COLUMN B IN C
NEED YOUR HELP THANK YOU
Hi MARRIAM,
Try using the following VLOOKUP formula, where $A$1:$B$100 is your range of data:
=IFERROR(VLOOKUP($C1, $A$1:$B$100, 2, FALSE), "")
I WANT CALCULATE LIKE THIS:
IF A1 Grater than date 31-05-2015
than A2*12.36% otherwise A2*14%
thats it but formula not giving me correct value
so Plz help me on this
IN ONE CELL
=ROUND(IF(A1>"31-05-2015",A2*14%,A2*12.36%),0)
AND I ALSO TRIED IN THE PLACE "31-05-2015" TO DATEVALUE("31-05-2015")
BUT NOT WORKING.
IT SHOWS #VALUE
YES MY FRIEND I FOUND MY SOLUTION AND IT WORKS
LIKE THIS
=ROUND(IF(T8>=DATEVALUE("01-06-2015"),E8*14%,E8*12.36%),0)
THANKS
AND DOING GOOD JOB (GENIUS WORK)
Good afternoon, I am trying to create a simple spreadsheet calculating a price per square foot value based on an optional selection of option A (wood material)or option B (carpet, which would be translated to square yards). both options A & B will also need to be increased by 20%. If I have all the correct numbers in the spread sheet, why cant I apply an if then statement to the column / cell I want to create the equation for? I am trying the following.
=IF(H7=Option A,"((F7*D27)*1.20))",(H7=Option B,"(((F7*.111111)*D28)*1.20))"
F7 represents the square feet
D27 represents the Price
H7 would be the field I would like to type option A or option B into
thank you for your help.
Hi Doug,
I believe the correct syntax is as follows:
=IF(H7="Option A", F7*D27*1.2, IF(H7="Option B", F7*0.111111*D28*1.2, ""))
How to put a single formula for the following;
If F31 is '0' then the value should be of H12...
and if F31 is more than '0' then the value should be the value of F32.
Hi Anwaar,
You can use a nested IF formula like this:
=IF(F31=0, H12, IF(F31>0, F32, ""))
Thanks a lot!☺
Good morning!
Now could u also help me out for the following:
I have different ranges of a quantity and one single cost for that particular range.
For Ex. 5000 to 10000 = Rs. 120000
11000 to 20000 = Rs. 115000
21000 to 30000 = Rs. 100000
31000 to 40000 = Rs. 98000
and same pattern continues for further more values...
request for early reply...
thanks in advance
Anwaar
Hi,
I am trying to create an IF formula on a date cell that states if the date is before or equal to 01/02/2015 then give me 'A' otherwise give my 'B' (ie. if the date is passed).
I have used =IF(D7<=01/02/2015,"A","B") but it does not work and gives me 'A' for dates before and after 01/02/2015.
Hope you can help.
Many Thanks
Hi Ross,
Just use the DATEVALUE function in the logical test:
=IF(D7<=DATEVALUE("1/2/2015"),"A","B")
Hi,
I need a solution for below,
Given data
Name Subject marks
Raj FFV01 70
Vino FSO03 80
In a desired cells, I need a formula that allows me to pick the Raj's "Subject" only and mark in the next cell. whereas if it's vino, Cell should be blank.
Please revert if quest not clear.
Thanks for your help in advance.
Hi Raj,
You can use a VLOOKUP formula similar to the below one:
Subject: =VLOOKUP("raj", A1:C100, 2, FALSE)
Mark: =VLOOKUP("raj", A1:C100, 3, FALSE)
Where Name is column A, Subject is column B and marks are in column C.
sorry it's not working
Hi NIRAV,
I am not quite sure what +c1 means. Anyway, if B1 is a date rather than a text value, the DATEVALUE function is not needed:
=IF(NOW()-B1<30,C1,0)
If B1 is a text value, then the following formula works fine:
=IF(NOW()-DATEVALUE(B1)<30,C1,0)
I am having a problem with the if function with this question9. cell C10 is equal to 0.
a. If this condition is true, the current cell should be made empty (that is, equal to "").
b. If this condition is false, the current cell should display the result of multiplying cell C10 (hours) by cell D7 (hourly wages). Use a relative reference to cell C10 and an absolute references to cell D7 so that the formula can be copied to other cells
Hi Janay,
Here you go:
=IF(C10=0, "", C10*$D$7)
HI!
I'm trying to use a certain cell name from a list in my IF formula, but it will not allow me to use the character within the name without trying to use the characters function. is there a way to override this? Thank you!
ex. =IF(D5=3Y) it's wanting to use that Y as a YEAR function and not allowing me to use it simply as a Y.
Hi Stephen,
If 3Y is a usual text string, then enclose it in double quotes like this:
=IF(D5="3Y", value_if_true, value_if_false)