Comments on: How to use IF function in Excel: examples for text, numbers, dates, blanks

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 58. Total comments: 4817

  1. I need help with a formula.
    I have a list of individual names some duplicate names. The duplicate names have test scores which I need to see if the score increased or decreased by when they took the test which is by date.
    How can i make a formula to look for multiple last names then look by date and score to get a result of increased +20 or decreased-20
    Example:

    Smith 200 9/25/2017
    Smith 175 9/1/2017

    Jones 150 9/24/2017
    Jones 180 9/1/2017

    I would appreciate if anyone knows how I can do this.

  2. I was wondering if anyone could help me out with an if statement.

    I have a figure in cell B5 I want to run an IF/OR statement on it to do the following:

    If B5 <5 then use the value in X5, OR if B5 = 5 AND 10, then use the value in X7

    Any help would be appreciated.

    1. Hi, use the below Formula i think it will work

      =IF(B5<5,X5,IF(OR(B5=5,B5=10),X7,""))

  3. Was hoping you could help me? Here is my current formula:
    =IF(ISNUMBER(E15),VLOOKUP(E15,ReferenceTables!$B$13:$C$26,2)-F15,"0")

    Now I'd like to add "IF H15, I15 or J15 show any text, reduce this number by one"

    Thanks!

    1. Hello, Josh,

      for us to be able to assist you better, please describe in more detail the last part of your condition with the text in H15, I15 and J15.

      If you still need help with this formula, it would be better if you could send us a small sample workbook with the data and the result you expect to get to support@ablebits.com. I kindly ask you to shorten your table to 10-20 rows.
      Don't forget to include the link to this comment.

      Our tech specialist will take a look at your task and try to help.

  4. Dear All,

    scenario as below.
    Price
    A1 B1
    1 YES
    2
    3
    4
    5
    i want to use formula wherein B1 Column populate automatically as "YES" to which the lower price is.

    Please help

    1. HI, IF(A1<=1,"YES","")

  5. dear sir/madam,
    i want to use IF function to come up with a formulae that will be giving me selling price basing on the below markup(in percentage);

    1)100≤Price of item ≥0 = 172.5%
    2)500 ≤ Price of item≥101 =137.5%
    3)5,000≤price of item≥501=77.5%
    4)20,000≤price of item≥5,001=57.5%
    5)40,000≤price of item≥20,001=77.5%
    6)100,000≤price of item≥40,001=37.5%
    7)Price of an item ≥100,001 =17.5%
    i want an excel sheet where i will be inserting the invoiced amount and the column with the formulae give me the selling price.

    thanks in advance.

    regards
    george

  6. =IF(C12<100,C12<200,C12<500,"C12*1,C12*1.5,C12*2")

  7. Hello,
    I'm trying to use if formula based upon Text value in a cell, but wanna use another 2 different if formula (for aging bucket based upon value of different column) based upon text matches or not.
    but unable to run it, anyone please help me

    =IF(OR(L2="GDC","=IF(J2<=7,"0-7 days",IF(J2<=30,"8-30 days",IF(J2<=45,"31-45 days",IF(J2<=60,"46-60 days",IF(J2<=90,"61-90 days",IF(J2<=180,"91-180 days",IF(J2<=365,"181-365 days","365+ days")))))))","=IF(J2<=2,"0-2 days",IF(J2<=5,"3-5 days",IF(J2 15 ")))"))

  8. Hi,

    I am trying to pull a number based on the input.

    IF(B24510030045, then result should be as C27 & B2 valus is >100<299 then C27...

    Can anyone help me to solve the issue for me..Thanks in advacne

    1. Hi,

      I am trying to pull a number based on the input.

      =IF(B245100300500,C6)))) IF the input value is B2 = 5 then result should be as C2 & B2 value is >100<299 then C4...

      Can anyone help me to solve the issue for me..Thanks in advance

  9. can someone help, looking for formula to yes or no if number in cell C1 is greater than or equal to 3 of number in cell B1.

  10. hi

    i want to know how to use Round function to the below formula

    =round(IF(G2<60,'Export Worksheet'!AD2*5%/365*G2,IF(G2<120,'Export Worksheet'!AD2*10%/365*G2,IF(G2<180,'Export Worksheet'!AD2*15%/365*G2))))

  11. can I get a formula to generate a pattern like this
    1
    1
    2
    2
    3
    3
    4
    4
    5
    5
    and so on.......

  12. Hi,

    I was hoping to get some help with my formula below:

    My cell E32 is interchangeable, could be 50, 45, 32, 0, e.t.c. I want the returned value to be in two (2) decimal place if condition is met in the formula. instead of just displaying 1, 2, 3, 4,5 in my formula it should give me exact value in 1 or 2 decimal places. i tried to add .0 to the formula but eachtime it keeps disappearing.

    =IF(AND(E32>0,E322.2,E324.4,E326.6,E328.8,E32<=11),5,"Out of Range")))))

    Thanks

    1. Sorry see correct formula:

      =IF(AND(E32>0,E322.2,E324.4,E326.6,E328.8,E32<=11),5,"Out of Range")))))

  13. Hello,
    I am trying to compare a date in C2 and if equal to a range of dates in another row =IF(C2=D5:D10,1,0)

  14. Hello.
    I want to use IF function, but dont it.
    For exmp.
    IF B4=1,B4=2,B4=3,B4=4 "BAD"
    IF B4=5,B4=6,B4=7,B4=8 "GOOD"
    IF B4=9,B4=10,B4=11,B4=12 "OK"
    IF B4=13 "SUPER"

  15. Thanks again

  16. Hi friends,

    kindly guide me for solve the problem i.e. "i need answer of a employee attendance it is in excel sheet that have P for present and .75 is leave of 1/4 and .5 is half day how can i solve it ?

    Lokendra Sahu P L P P P P P P L P 0.75 P 0.50 P P L P P P P P P L P P P P P P L P 24 7.00 0 31

  17. I have a cell (say A1) contain values like this format:0.453, 0.583, 0.383. I want to get each number from cell and compare if they are > 1. And I write this for 1st number(0.453): =IF(LEFT(A1,5)>1, 1, 0)
    It return 1 which is not correct. I check "LEFT(A1,5)>1" can return 0.453. Thanks for your advice.

  18. I have the operation like this:
    =if(A1=8,50,"")

    What will i do if i will add the operation like A1 =0,0

    How do i include that on my operation. Thanks thanks

  19. i have to calculate overtime data

    OE Names Orders Processed Target Extra Orders
    Amit Singh 38 40 -2

    Now i only want to pay overtime if my team members have met the target and they can get the overtime paid for whatever extra orders they have processed else the variance cell should indicate 0 for not having earned any overtime.

  20. Hello,
    I'm using excel 2010.
    In cell D2 is a date. F.e. 07/08/2017
    In cell G2 is a value F.e. 38
    I would like to use a formula in cell I2, which will give me the value from cell G2, if the date in cell D2 is greater or equal than 28/08/2017.. I am currently using the formula: IF(D228/08/2017;G2;IF(D2<28/08/2017;""))
    So normally in my example, the outcome should be "" because the date in cell D2 is smaller than 28/08/2017 but it doesn't...

      1. Natalia,

        I have been struggling with date ranges within IF formulas, but your response to Glenn helped me greatly. Many thanks.

  21. I have used a simple IF statement to identify Pass/Fail conditions.

    IF(I4>1, "FAIL", "PASS"). As long as I4 contains actual results, this works fine.

    But sometimes there is text in I4 (see note, etc.). Since the text is not >1, the result should be PASS, but I'm getting FAIL.

    So I turned it around: IF(I4<=1, "PASS", "FAIL"), but the results are the same, FAIL when there's text in I4.

    Can you explain this?

    (Still) using Excel 2003 (I hate the ribbons).

    Thanks

    1. Hi,

      You need an additional condition that will check if the values in I4 is number. Please try the formula below:
      =IF(AND(ISNUMBER(I4),I4>1),"FAIL","PASS")

      You can read here how AND logic is used in formulas.
      Hope this helps.

  22. Hi

    I have value in a cell(A1) like "01-USA" (This is fixed Cell Value)
    Another Cell(A2) value is changing as per country selection but sometimes value comes same as in fixed cell. Please note both cells have text value only.
    so I want following results

    If A2 value is same as A1 then result like 10-5 =5
    If A2(02--Canada) value is different from A1(01-USA) then result must be Blank

    Thanks in advance for your help.

    1. Hi, Surya,

      as far as I can see, you have all the conditions to build a nested IF. Please check this tutorial to learn how it's made. There are lots of examples as well.

      Also, in case you don't know how to show if the values are not equal, I'd recommend you to look through this article as well.

      Hope these pieces of info will help you solve the task.

  23. Hi Sveltalana ,
    I have 2 cells with dates(A2, B2) , i would like B2 to highlight if it is larger than 180 days / 6 months than cell A2

  24. what would be the formula

    if the sum total in C10 is less than or equal to 300 the cell should show 300 but if C10 is greater than 300 then it should pick the C10 value.

    can you help me in this

  25. I am trying to produce a number in a cell.

    The number must come from column F when then column C and column N match a specific text.

    The formula I have tried only give FALSE results.

    =IF(AND('Sheet1'C:C="XYZ", 'Sheet1'!N:N="ABC"), 'Sheet1'!F:F, "N/A")

    Any help would be appreciated.

    1. Hello, David,

      I'm afraid this formula won't work like this.

      If you need to return only one number from each F cell, you need to use a separate formula for each separate cell, like:
      =IF(AND(‘Sheet1’C2=”XYZ”, ‘Sheet1’!N2=”ABC”), ‘Sheet1’!F2, “N/A”)
      (you can place the formula into one cell, and copy it down the column)

      Ii you need to perform some mathematical operation with the found values, you need to enclose the whole IF formula into COUNT, or SUM, or AVERAGE, or some other function depending on the operation you need. In this case it is an array formula. It is entered by pressing Ctrl+Shift+Enter on your keyboard instead of just Enter.

      Hope this helps!

  26. Hi,
    I have a workbook consisting of two worksheets.
    On worksheet one I record who has taken what showing quantity and sizes.
    On worksheet two I am keeping a usage report of those same items handed to numerous contractors(stock, ppe etc) showing size and quantity usage.
    I want a formula put on w/s 2 cell Q4 that if on worksheet 1 in block C4 the value is "S" then the value of q4 must be the same as the value in D4 on w/s 1.
    Can you help please.
    Thanks
    Emcee

  27. Hi, I have a problem while using IF function.

    IAm trying to use if function Column B & C with a formula that if column B contains CLOSED than C should be CURRENT date and the formula is " =IF(B2="CLOSED",TODAY(),"") ".

    It is working correctly, however, while opening the excel sheet in the next day, it is reflecting the current day and it is not reflecting the date which I actually enter CLOSED in column B on the particular date.

    Can someone please help me to fix, what exactly am I doing wrong here?

    Thanks,
    Paddy

  28. Hi,

    I was looking at doing a formula like the below;

    =IF(ISNUMBER(SEARCH(”P”,D19,3)),(VLOOKUP(D19,'Rates Summary '!A$2:Q$1573,2,0)),D19)

    Basically, I have a code "QAPLI0" in cell D19. What i want to do is convert this to a QAR code which is what my Vlookup is for. Only problem is that when i already have a QAR code in the cell D19 it still brings me back a QAP instead of leaving it was whats already in the cell D19 which is what i though i had down as the "value if false" part of the IF statement.

    Am i making sense? I tried to use a FIND instead of SEARCH but got the same result. Am i missing something here?

    Any help would be great.

    Thanks
    Jon

    1. Hi, John,

      Please note that you have smart quotes instead of double ones in SEARCH(”P”
      If this is the way the formula is written in Excel, ISNUMBER will always return false.
      Also, ’Rates Summary ‘ has space at the end.

      If this doesn't solve your problem, please send us your workbook to take a look at to support@ablebits.com. Please don't worry if you have confidential information there, we never disclose the data we get from our customers and delete it as soon as the problem is resolved.

  29. So I am trying to make a call schedule for my work and am having trouble creating a formula that will help me. What I am looking to do is have the Initial Call date (A) and a column for the call back date (B). I want excel to fill in the call back date for me (B) for a certain length of time per my customers buying level.
    Ex: If customer is "gold level" (C) and the initial call date (A) is 1/1/2017 then call back in 30 days or 1 month (2/1/2017) (B) or,
    If customer is "silver level" (C) and the initial call date (A) is 1/1/2017 then call back in 60 days or 2 months (3/1/2017) (B).
    Can this be done? Thanks for the help!

  30. For one of our lab tests, we take 2 weights. The second can't be more than 0.4 away from the first. If it is, then we have to do a third weight. I need the "residue" cell to calculate depending on that. If the second weight is within 0.4, I need it to use that. If not, there will be a third weight entered, and I need the "residue" cell to calculate based on that one. Can anyone help?!?

  31. Oilgaztreyd LLC has been in business of production, marketing and exporting of all petroleum and petrochemical products for the past 15 years. We have been an established and popular company with an excellent track record for the best customer satisfaction. We have never compromised on the quality and the services provided to the customer. We believe in keeping the customers happy and providing them with products at a very competent price. We have an excellent staffs who will guide you with their best ideas by keeping in constant touch with your company and informing about the market trends. We are also interested to establish a mutual business relationship with buyers, facilitators and resellers all over the world with basic aim of supplying them with our products such as follow D2, jetFuel A1,JP54,Mazut M100,D6,Base Oil and Bitumen.

    Also we work with other foreign partnered refineries in allocation production.

    Regards,
    Julian Alessandov
    Email:oilandgaztreyd@mail.ru
    Email:oilandgaztrey@yandex.ru

  32. Hi All,

    I need to come with an IF formula for the following- it keeps telling it too many arguments

    IF 76=170 >141=200

  33. HI,
    CAN YOU SUGGEST ME FORMULA FOR THIS:-

    A B C D E
    INPUT OUTPUT BALANCE LIABILITY

    1 IGST 150000.00 175000.00 -25000.00
    2 CGST 57500.00 37500.00 20000.00
    3 SGST 57500.00 37500.00 20000.00

    1. PUT A FORMULA IN E1, IF D1 IS LESS THAN 0, THEN D1 CAN TAKE BALANCE FROM FIRST D2 THEN D3, IF NOT LESS THAN 0, THEN NOTHING.

    (LIKE IF D1 IS -25000, THEN D1 TAKE BALANCE OF 20000 FROM D2, AND 5000 FROM D3, THAN E1 BALANCE IS 0, E2 BALANCE IS 0, E3 BALANCE IS 15000.)

  34. Hi guyz,
    can you guys help me with a formula that can work with time.
    my situation is that i have to add 15 mins to people time who come after 8:04 am if they come before 8:04 am it should read 8:00.

  35. I didn't make my example ,clear. I have column "A" with these numbers 5 4 2 3 6 7 - In column "B" I have these numbers 30.92 , 31.29 , 31.11 ,31.17, 31.29, 31.07 If i select a number in column A or an adjacent number I want the minimum corresponding number in column "B" I need a formula for this. I tried this formula but all i get is zero.=MIN(IF(A4:A9>4,A4:A9<8,B4:B9)). i used control, shift, enter.I added some commas between some of the numbers to make it clearer.

  36. Hi All,

    I am looking for assistance in developing one syntax where there could be three different conditions. Those conditions could be -

    1. If Date Is not crossed then Display date
    2. If Date Is crossed and status is not updated then "Planned Date Crossed, No status updated"
    3. If Date Is crossed and status is updated then Variance number between Plan Vs Actual Date.

    Excel have to verify certain details in the table before these three conditions could be verified. So one may have to use index match formula for the same.

    Also, the single cell number format should change automatically based on the cell value which could be date (First Criteria), numeric (Second Criteria) and text (Third Criteria).

    It looks pretty tough to me. Can anyone help on the same.

    Best

  37. Hi there,

    Can help me on this question.

    Cell B Cell C Cell D
    Point Eastings Northings Row 2
    1 567768 6376890
    2 567702 6376035
    3 567835 6377836
    4 567936 6376471
    5 568035 6376044
    6 566834 6377837
    7 567413 6378635
    8 566036 6378999
    9 568634 6377941
    10 566345 6376534

    1st Point
    2nd Point
    Diff East
    Diff North
    Distance

    I'm trying to use vlookup to calculate the distance between two points.
    I need to be able to choose any point I wish and type that into cell D14 (starting point). Then the same thing for the end
    point in cell D15. The difference between eastings and northings of both slected point will be display in cell D16 and D17.
    The distance (=SQRT(DiffEast^2 + DiffNorth^2) between two points will be displayed in D18.

  38. hii

  39. Hi,

    I am trying to use the if function but I am trying to use it for 3 different results
    if a number is lower than 18 if should say approved
    if it is between 18 and 24 it should say approaching
    and if the number is larger than 24 it should say finished

    I was able to use this formula like this
    =if(A2<18, "approved", "") that is what I am using but the problem is that the numbers contantly change and I need for it to include the 3 posibilities but this formula does nto allow me.

    Please help

  40. Hi!

    I've been identifying non-integer numbers on large datasets using this formula (cell F2 for example):
    =IF(INT(F2)=F2, 0, 1)
    It works great...until you drag the function past 44,000 or so rows, and then it stops working.

    Any suggestions why or a workaround?

    Thanks in advance!

  41. I am working on putting my budget on excel, and not sure how to have adding the amounts as they are enter to the correct category.
    =IF( EXACT(F6:F200,"Car Insurance"),0,SUM(G6:G200))
    what I am trying to accomplish here is that when i choose my category on F6 TO F200 from a drop down list, Car Insurance is an example, but i have electricity, cell phone, groceries, etc. After i choose my category next to it n G6 TO G200 I enter the expense amount for that day for that specific category. I want to create an statement that say if f6=ELECTRICITY, then use add G8 put it on another cell, b6, etc, if f6=cell phone, then add G6 to b8, etc.

  42. Trying to determine the lowest rating for a given security with two different ratings. If A1=Baa1 and B1=A3, the formula should return a value of Baa1 given the following hierarchy of ratings from highest to lowest (Aaa, Aa1, Aa2, Aa3, A1, A3, A3, Baa1, Baa2, Baa3, etc.). Thanks.

  43. plz help me...
    1000000< marks 1, other every Lilian 1 marks and full marks 06

  44. Mine seems simple. I need

    Formula in H10
    If C10 contains "Payment" Then enter the sum that's in G10 into H10
    So if it's a payment I need the sum to move right one cell
    and yet I cant figure it out.

    Thanks

    1. I DID IT!

      =IF(C10="Payment",G10,"0")

  45. I have an interesting question and I am not sure if it is even possible.

    Can this be done? IF cell A1 = PR Then INCLUDE a 0 in Cell B1

    What I am trying to accomplish is adding a 0 to a zipcode. For example the state PR has zipcodes that begin with a 0 so if the cell has the text PR then INCLUDE a 0 to the cell that contains the zipcode.

    Is this possible?

  46. I am looking to join two cells together but separate the two values by a comma into a new cell.Can someone supply an =if statement that would help for this?

    1. Hi there! I do this often to combine two cells with only a space separating and it's super easy. You simply add a new column and within that new column, you type in "=G2&","&H2" . The G2 & H2 simply represent the cells you want to combine. What you have in between the quotations is what is entered in between the combination, etc. Then do a drill down down the column for all others and you're all set!

  47. Hi,
    I'm Looking IF Formula For My Expense Sheet For Example In B1 I Write Anything Accept Leave Of Day Off So In C1 I Need Number 200 & When In C1 I Get 200 So In D1 Automatic I Get 250.

    Looking for Your Reply.

  48. Sir/Madam,
    While awarding grades to particular mark range, I want a '-' where the marks are zero . I applied this formula but it doesn't seem to work.

    =IF(BX9>90,"A1",IF(BX9>80,"A2",IF(BX9>70,"B1",IF(BX9>60,"B2",IF(BX9>50,"C1",IF(BX9>40,"C2",IF(BX9>32,"D",IF(BX9<=32,"E",IF(BX9=0,"-",IF(I8="AB","AB"," "))))))))))

    Kindly guide me.
    Thanks in advance .
    Malar

    1. Dear Malar as I have understood IF function it has three parts. Logic (greater, equal, less than etc), true or false parts. What you are trying to do is to put 10 IF functions in one cell. So I think it will not work. If you want to put "-" where marks are zero use this
      IF(BX9=0, "-", "")
      if BX 9 is zero it will return - value in cell other wise it will be empty.
      or use IF(BX9=0, "-", BX9) it will return original value if its not zero.
      As I understood you what you are trying to do is not possible with IF function. You have to find other function for this.

  49. If values in A1:A10 are in numbers and values in B1:B10 are alphabets. some of the values are empty between B1:B10 like B3, B4, B7, B8. how to calculate values of A3, A4, A7, A8 with formula.

  50. I am trying to add a column of money if the number opposite = the number 50

    =IF((J44:J55=50,sum(I44:I56),0)) - but this doesn't work

    Tks in advance.

    1. =SUMIF((J44:J55,"50",I44:I56)

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)