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 100. Total comments: 4830

  1. Ps: Can i do this with Countif function?

  2. Hi again,i need some help.
    In GDP column i have numbers equaled to the current year GDP.I want to count the values in the whole GDP column. In one cell to have information how many values i have in column GDP.Thanks!
    Sashko

  3. Hi Just to add to the above point i need to show the total number of due items in the next row

    Total Amount Due :
    Total Number of Due Invoices

  4. Hi,

    I am trying for a formula where if Column H is having due it should sum the total amount of Due from Column F

    For example =IF((H9:H70)="Due","SUM(F9,F70)",0)

    Column H contains Paid and Due
    Please advised.

  5. Hi, I need to write a formula to achieve following.

    If (cell No.) is >1 and 1100 then "350" and If (cell No.) is >1101 and <2100 then "300" and so on

    Can anyone help?

    Thanks in Advance

    1. hi,

      =IF(AND(A1>1,A1=1101,A1<=2100),"300",""))

    2. Hi,

      =IF(AND(J12>1,J12=1101,J12<=2100),"300",""))

  6. Hi, I need to write a formula to achieve following.

    If (cell No.) is >1 and 1101 and 2101 and <3100 then "250" and so on......
    Can anyone help?

    Thanks in Advance

  7. Hello. What a wonderful resource! I've learned a lot but unfortunately, not a solution to my problem. In column B I have a dollar amount. Column C is a dollar amount too, but by way of the vlookup function, so if there is no value returned, it has #N/A. I am trying to add columns B and C, but if column C is #N/A then you get #N/A when trying to add the two columns. I thought that if I used the IF function and said if C is > 0, then add the two columns, but if that argument is not true (it's #N/A), then just list what's in B. In other words, if columns B and C both have a dollar amount, then add them in column C. If column C does not have a dollar amount, then just list what's in B. Perhaps I should be approaching this differently?
    Thank you very much for any assistance you can provide.

    1. Hello Steve,

      Thank you very much for your feedback!

      You can use the following formula for your task:
      =IF(ISNUMBER(C2),B2+C2,B2)

  8. This formula works if the 2 cases are true:
    =IF(AND(J4<50%, N4<75%), "Mit Attendance < 50%; Toes Cut < 75%")

    I want to also add that if J4 is true, to output "Mit Attendance < 50%" and if N4 is true to output "Toes Cut < 75%".

    How do I combine them to get 3 possible outputs? Thanks for your help.

  9. Hi,

    how bout if I return the value of the difference of two cells for the false item? goes something like this =if(A2=B2, "ok", =A2-B2). I tried that one but it says the formula contains an error, then it recommended this one, =if(A2=B2, "ok", =difference(A2-B2)), but again, no luck was achieved. A little help please. Thanks.

    1. Hello, Marjorie,

      Please modify your formula so that it looks the following way:
      =if(A2=B2, "ok", A2-B2)

  10. It still was not working correctly but I figured the problem was bcos I did not put % sign in the formula. My cells are all in percentages.
    This is the one that worked:
    =IF(AND(I11>=50%, L11>=75%), "Qualified", "Disqualified")

    Thank you very much!

  11. Hi,

    I need 1 to be low, 2 to be medium and 3 to be high.
    I tried out =IF(A5=''LOW'',''1'',,) but error. Where is the error and how can I correct them?

    1. Hi Farah,

      Try this formula:

      =IF(A5="low", 1, IF(A5="medium", 2, IF(A5="high", 3, "")))

  12. formula below:
    =IF(AND(I11>=50, L11>=75), "Qualified", "Disqualified")

    1. Hello Gbesimi,

      Your formula is correct. Please carefully check your entry and numbers. I say this because if I11=49 and L11=75, it will show "Disqualified" as instructed; and vice versa. If there is still an error, please provide an example and I will help to the best of my ability.

      Mr. Ninja

  13. Pls see formula below. Atho both conditions are met, it is giving me Disqualified. Thank you.

  14. Hello Sashko,

    I believe I understand your question now. Every cell that contains the number '24', you would like to add 48 but if not, then sum all the numbers together. So if A1=24, B1=24, and C1=3; then your total you want would be 96, correct? On the other side, if A1=1, B1=2, and C1=3; then your total would be 6. This is what I am understanding from your clarification. If this is correct, I would use the formula below to calculate and verify if any cells contain the specific number '24'.

    =IF(COUNTIF(A1:C1,24)>0,COUNTIF(A1:C1,24)*48,SUM(A1:C1))

    Please verify if this is what you are wanting.

    Mr. Ninja

    1. Hi,Ninja.
      Yes that is it ! It worked! Thanks for the help!

  15. Hi,
    I just cant figure it out how to do this so in cells A2 to C2 i have numbers.I want in cell D2 to get the sum of the numbers with the following conditions if any number is equaled to 24 in cells A2 to C2 that cell in the sum(D2 ) to be 48! Any cell! i just cant fugure it out! Can you help me?
    Sashko

    1. Hello Sashko,

      To clarify, are the cells that contain value A2, B2, and C2? If so I would use this:

      =IF(OR(A2=24,B2=24,C2=24),48,SUM(B7+C7+D7))

      If not, please help clear up the confusion for a better answer.

      Ninja

      1. Hi,Ninja well it is hard for to explain but i will say it that way
        If i have one cell for example C2 yes the result is 48 but i want if D2 is also 24 the sum to be 2.48=96 for every 24 to have 48 plus.I hope you understood the problem.Thanks!
        Sashko

        1. Hello Sashko,

          I believe I understand your question now. Every cell that contains the number '24', you would like to add 48 but if not, then sum all the numbers together. So if A1=24, B1=24, and C1=3; then your total you want would be 96, correct? On the other side, if A1=1, B1=2, and C1=3; then your total would be 6. This is what I am understanding from your clarification. If this is correct, I would use the formula below to calculate and verify if any cells contain the specific number '24'.

          =IF(COUNTIF(A1:C1,24)>0,COUNTIF(A1:C1,24)*48,SUM(A1:C1))

          Please verify if this is what you are wanting.

          Mr. Ninja

  16. Which nottation is used 1 to 100

    thanks and regards
    Ratheesh

  17. Hi,
    I'm a day trader. I fetch data from Internet and the Market price updates in a particular cell in My Excel Professional Plus 2010. Is there any method where I can fetch that changing number and make it to a list of numbers updated by ticks so that during aftermarket time I could use those numbers for analyzing the data.
    Thank you in Advance.
    Riaz

    1. How do you fetch the data from the internet pls?

  18. Hi Svetlana,

    I was wondering if you could help me out? I'm trying to update a formula in a cell which takes information from a set of cells which, in turn are subject to information from another set of cells.

    E.g.

    A1 Apples C1 Bananas
    A2 Oranges C2 Plums
    A3 Pears C3 Peaches

    One of A1, A2, A3 will populate A4 depending on information in cells B1-B3 (say highest number), likewise C4 from C1-C3 depending on information from cells D1-D3.

    I'm trying to write a formula in A6 based on the data from A4 and C4 again depending on which has the highest number in cells B4 and D4. The formula is something along the lines of =IF(AND(B4>D4),"data from A4", "data from C4").

    As the information in cells A4, and C4 are subject to data from cells A1, A2, A3, B1, B2 & B3 and C1, C2, C3, D1, D2, & D3 respectively while A6 is subject to data from A4, B4, C4 & D4, how do I create the formula in A6 which takes in the data which is subject to change as opposed to any text e.g. "data from A4"?

    If you can follow all of that I would appreciate any help you can give.

    Thank you in advance,

    Darren

    1. Hi Darren,

      If your task is to return the number from A4 if the number in B4 is larger than the number in D4, and otherwise return the number from C4, then you can use the following formula in A6:
      =IF(B4>D4,A4,C4)

  19. how can solve this problem
    if 200 captured 4, 600 captured 8,& 1000 captured 10
    pl. give the correct link

    1. Hi,

      use this below formula, I have taken 200, 600, 1000 in Column "A"

      =IF(A1=200,"4",IF(A1=600,"8",IF(A1=1000,"10","")))

      1. Hi Hemanth,
        thanks for info.
        but we need if any value is less than 200 it's captured "4"
        if its 400 to 599 its captured "6" & it's 600 or above then itwill be captured "10"

        Pl help

        1. Hi,

          =IF(AND(J10>0,J10=400,J10=600,"10","")))

  20. =IF(AND(A7>=5.5,A7=5.5 and <=13

    true = A7-0.5
    false= if A7<5.5 true A7 False A7-1.

    Please help me!

    1. Hi Grissy,

      Here you go:

      =IF(AND(A7>=5.5, A7<=13), A7-0.5, IF(A7<5.5, A7, A7-1))

  21. If A7>=5.5 and A7<=13 then A7-0.5,

    if no then if A7<5.5,A7,A7-0.5

    Can you help me
    Pretty please!!! =)

  22. Hi Svetlana,
    there is a 9 figure number and a character(ex. 7730082766V) in a1. what I want is if the 3rd number of that number less than or equal 3, print "male" or if it is bigger than or equal 5, print "female" in b2. i tried with =if(mid(a1,3,1)<=3,"male","female") formula in b2. but it doesn't work. help me.

    1. Hi Chaminda,

      The point is the MID function always returns a text string, even if the original value is a number. You can simply multiply the result by 1 to convert it back to number, like this:

      =IF(MID(A1,3,1)*1<=3,"male","female")

      Alternatively, you can use the NUMBERVALUE function:

      =IF(NUMBERVALUE(MID(A1,3,1))<=3,"male","female")

  23. hi
    iwant formulas Please explain i need help

  24. I am trying to write a formula using data from a different tab that says "if cell in column A is not blank, count the number of cells in column V which are not blank". And make this applicable for an unlimited number of rows.

    I have tried amongst others;
    =COUNTIF('Action Register'!A2:A100,"",'Action Register'!V2:V100"")

    =COUNT(IF('Action Register'!A2:A100,""), AND, IF('Action
    Register'!V2:V100""))

    I am getting a standard error message to say there is a problem with the formula every time. Any suggestions?

  25. Kindly help me,
    i want to apply formula ( IF function formula for text values ) to multi ple columns but i am not able to do

  26. I would like to create multiple condition in single column

    If 88000-44000 is more than 50% then multiply with 0.06% or equal to 50% then multiply with 0.14% of less than 50% then multiply with 0.21%

    please arrange the same formula.

  27. I have created 3 lists for date drop down menus. The lists are Month (Jan-Dec), Day (1-31), and Year (2016-2020). The problem I am trying to find a formula for is this: If February is selected as the Month, how do I prevent the days of 29 (for non-Leap Years) and 30-31 for all years to be selected from the Day drop down list? Not sure if Conditional Formatting or Data Validation is the way to go. If there is not a way to specifically prevent them from selecting 29-31 from the Day drop down list, then how to generate an error message when 29-31 is selected? Your help is greatly appreciated.

  28. HI,

    I need a small clarification in excel formula.

    =COUNTIF(J6:J27,"Not Met")

    I NEED A FORMULA FOR INDIVIDUAL DATES MET OR NOT MET. CAN ANY ONE HELP ON THIS
    E F G H I J K
    DATE START END TAT VOLUME SLA 13:00
    2/13/2016 4:47 PM 12:00 26 Met
    2/13/2016 15:00 35 Not Met
    2/13/2016 12:12 45 Met
    2/13/2016 13:14 82 Not Met
    2/13/2016 15:00 1 Not Met
    2/13/2016 12:12 45 Met
    2/13/2016 13:14 82 Not Met
    2/13/2016 15:00 1 Not Met
    2/14/2016 12:12 45 Met
    2/14/2016 13:14 45 Not Met
    2/14/2016 12:00 45 Met
    2/14/2016 15:00 45 Not Met
    2/14/2016 12:12 82 Met
    2/14/2016 13:14 26 Not Met
    2/15/2016 12:00 35 Met
    2/15/2016 15:00 45 Not Met
    2/15/2016 12:12 82 Met
    2/15/2016 13:14 1 Not Met
    2/15/2016 12:00 45 Met
    2/15/2016 15:00 82 Not Met
    2/15/2016 12:12 1 Met
    2/15/2016 13:14 45 Not Met

  29. Hello there
    Can anyone help me with this function, please: =IF(14<D9<17),"15"
    I need that the cell takes the value of number "15" if the value from the equation in "D9" is between 14 and 17.
    Thanks in advance

    1. Hello!

      Here you go:
      =IF(AND(D9>14, D9<17), 15, "")

  30. Dear all

    Please tell me formula for

    If sheet1 cell A1 dated match with sheet 2 date's column A:A
    Ans will Sheet1 B1

    1. Hi Ravi,

      Use this formula in Sheet1 B1 cell.

      =MATCH(A1,Sheet2!A1)

      1. Hi Ravi

        if its match will show "match" not match will show "blank cell"

        =IF(MATCH(A1,Sheet2!A:A),"match","")

  31. I need a formula for a table which I'm making which shows if someone has been active on Social Media for more than 30 minutes or not.(project with many members). I also want the cell to be colored Green, if active and red if inactive. Is this possible and how can I do that? Can someone give me the formula. Will be appreciated.

    Thanks

  32. Hello,

    I have two columns, one contains names, the other contains numbers. I have the names sorted in order I need so there are blank cells (i.e. A1=John, A2=Blank, A3=Joe, etc.) The other columns contains the numbers to match the names. But there are no blank cells (i.e. C1=2, C2=3, C3=4, etc.) How do I match the numbers to show next to the names and skip the blanks? So B1=2, B2=Blank, B3=3) I tried the IF function to pull data that contains text but what do I enter so that the numbers are shown next to the names? Thank you in advance for any help.

  33. I have a question, can you help me please?
    If I have multiple sheets, for example sheet1, sheet2, sheet3 and sheet4. And each sheet has 4 columns. The first one has a reference number , the second has an information , the third has a time , the forth has a date.
    I want to put if statement, for example if i put reference number 25 in sheet4, I want it to do a search itself in the whole sheets and to copy whole the data from whole sheets & whole columns to this specific sheet
    How???
    can u help me ??

  34. Hi.
    In pivot table report I want to publish report in below format.

    Opening stock,REceived qty,Issued qty,Closing stock

    to get this report in pivot table, what should be the format of reference data.

    Thanking you..

  35. Good day,

    I can't get the border format to follow the cell I'm copying in value_if_true in the IF command.
    =IF(C13="Description",C18,"") where C18 is a value with the darken top border.
    Maybe it can't be done with the IF command but if so, I will appreciate any help in this matter. I have over 640 lines to correct and doing it by hand is time consuming.
    I could probably write a macro...

    Sincerely,

    Robert

    1. Hello Robert,

      The only thing formulas can do is change the value of the cell where they are entered. If you need to change the format of the cell at the same time, please create a conditional formatting rule that will change its border or color the way you set. If you want to change the border of the cell if it contains the word "Description", you will need to use the following formula in your conditional formatting rule:
      =C13="Description"

  36. Hello,

    assume i have written in one column 100(Cell A1), 200(Cell A2), 300(Cell A3), 400(Cell A4), 500(Cell A5), 600(Cell A6). I want to multiply these by 1.25 and display the values in the same cell. eg. Cell A1 is currently display 100. Once it is multiply, the value is 125. Then that value should appear in the cell A1 instead of 100.
    Can someone support me.

    Dinesh

  37. Can you give me a formula for this? To get the current name... Cell A has name then the condition, if the the cell B is empty value Cell A, if the Cell C is empty value cell B, if the cell D is empty value cell C, otherwise value current cell. Thanks.

  38. hi
    need help in getting the value from another sheet if one condition is matched. the condition could be a unique number. can this be done by IF formula.
    i did on a sample sheet and it was correct, however when i actually implemented on the actual sheet, the result shows 'FALSE'.
    formula used i was as under
    =IF(A2=DCR!B2,DCR!A2)

    thanks

  39. Hello, Is there a formula which would be able to tell me the following. I have already an if formula to find out if it equals 80% of a gross loan(which also has other factors such as fees, interest charged depending on how long the loan has been held for,) however if they don't equal 80% I have to have a calculation to find out what the value needs to be to equal 80% is this possible?

    This is so I can have a calculator where someone can put the all the details in and it tells them what the figures need to be.
    Many thanks in advance

    Amy

  40. dear madam,
    i want to =if(c2"","completed","") please inform me to learning it.
    WARM REGARDS,
    NAVEEN.R

    1. Hello Naveen,

      Most likely you need the following formula:
      =if(c2<>"","completed","")

      You can learn how to work with the IF function from the blog post above.

  41. Dear Mam,

    I am Working as Business Analyst. how can i give a ranking to the companies based on their MAT score with IF function.

    please clarify

  42. I am working on a spreadsheet for a game challenge. I have a list of options: Baby, Child, Teen, Young Adult, Adult. The values are respectively: 0, 3, 16, 29, 49. I'm unsure how to write an IF function to add an option from the list's value + another cell that will be filled in. I think it should be =IF(A1="Baby", 0) But how would I put all the options in there? Basically, how would I make it so that whatever option is chosen, it would return the right value and then add it to the cell?

    1. Hi Wolfy,

      This can be done by using nested If functions, e.g.:

      =IF(A1="Baby",0, IF(A1="Child",3, IF(A1="Teen",16, IF(A1="Young Adult",29, IF(A1="Adult",49,"")))))

  43. Hello, I just ran into a problem with a formula i had help on before. I have 5 vehicles that i use in a spread sheet. i need a formula that will prevent from incorrect information because of odometer numbers running together. i use another spreadsheet with additional vehicles and the odometer readings are similar. =IF(C14>=174121, 15, IF(C14>=227425, 5, IF(C14>=208012, 21, IF(C14>=143916=72700, 9, 0)))))
    #2 odometer is at 143916 #5 227425 #9 72749 #15 174121 #21 208012 Please help, thank you for your time, very much appreciated!

    1. Hello, I believe I figured it out--- =IF(C33>=227425, 5, IF(C33>=208012, 21, IF(C33>=174121,15, IF(C33>=143916, 2, IF(C33>=72700, 9, 0))))) Formula in the correct sequence resolved problem, if incorrect, please let me know. Thank you

      Reply

      1. Yes, the updated formula is correct. Putting logical tests in the correct order is critical because as soon as the first condition is met, other logical tests are not checked.

  44. Hi Svetlana. Thanks for the last reply, it was very helpful. However, I have a new problem I am struggling with.
    I have a list of names in column A and B and I want see all identical names as "true" in column C. I have only managed to make an if-function which compare e.g. A2 with B2, but what I would like to do is to compare A2 with the whole range of names in column B. Something like =IF(A2=B2:$B$5626, TRUE). This does not work for me for some reason, do you know why?

    1. Hi Andreas,

      The IF function cannot compare ranges. I think you can use the following formula:

      =IF(COUNTIF($B$2:$B$5626, $A2)>0, TRUE, "")

  45. Please help, I need my formula to say if age is between 25-30 then its a certain cell, if its 31-40 than its another cell. how can I write it?

  46. Hello,
    How can I assign a number to a text value and then add it?

    Data Validation is present in A1, A2 & A3
    Yes, No, Maybe are the values

    I want to assign Yes=1, No=0; Maybe=.5 and then be able to add those values,

    Example:
    A1=Yes (1)
    A2=No (0)
    A3=Maybe (.5)
    Total should be 1.5

    Thank you in advance for your help!

    1. Hello Michelle,

      You need to add a column for the formula that will assign a number to the values in column A:
      =IF(A1="Yes",1,IF(A1="No",0, IF(A1="Maybe",0.5,"")))

      Copy it down the new column to get a number for each cell in column A. Then you can use the SUM function to add the values you get.

  47. Светлана, would you be so kind to give me a hand on the following please? Assumption, in Sheet1 I have A1: toiletries ; A2: washing liquids A3: powders A4: toiletries; A5: conditioner etc. In Sheet2 I have B1: washing liquids; B2 powders, B3: shampoos; B4: toiletries; B5: shampoos etc. I Sheet2 I also have in C1: 213; C2: 325; C3: 564; C4: 912; C5: 487 etc.

    My objective is: In cell F1 to have the following result -> If value in A1 (sheet1) matches value in B1 (sheet2), then return value from C1 (sheet2).

    You help is very much appreciated. If you need more clarification on this matter please let me know. Зарание спасибо. Alex

    1. Hi Alex,

      If my understanding of the task is correct, you can use the following formula:

      =IF(Sheet1!A1=Sheet2!B1, Sheet2!C1, "")

      1. Светлана,thank you for your prompt response. Actually, I have realized the objective I have outlined is entirely incorrect. The actual output is: If VALUE in B1 matches the VALUE in the range A1:A5, then return the VALUE from C1. Correspondingly, when formula goes to B2 it has to check the range A1:A5 and if there is a match it returns the VALUE from C2.
        Apologies for the confusion caused.

        1. Светлана, no need to bother. I have managed to figure it out. Thank you anyway! Best Regards, Alex

  48. Hi,

    I have 3 column A, B,C and if A=B=C is Thrue, if not is False

    Please can you help?

    Thanks,

    Loredana

  49. Hi,

    I need help trying to correct this formula.

    =IF(OR(SUM(G8:R8)=0,(D7+F8),(SUM(G8:R8)0)),(D7-E8))

    I am trying to have it read
    if the sum of G8:R8 = 0 then add D7 + F8
    if the sum of G8:R8 does not equal 0 then Subtract E8 from D7

    However, it currently only Subtracts E8 from D7

    1. Hello Karen,

      You can use the following formula for your task:
      =IF(SUM(G8:R8)=0,D7+F8,D7-E8)

  50. Hi,
    I am trying to use the IF formula, but need it to have more than two options, and I can't make it work. Please can you help?
    e.g.
    Grades are listed in Column B of the sheet. Then in column C I want to add the grade description.
    If Column B = A, then I want column C to say Good.
    If Column B = B, then I want column C to say Medium.
    If Column B = C, then I want column C to say Bad.
    When writing the formula please use cell B2 and C2 as the cells that the data is in. Thanks
    Please can you advise the formula?

    1. Hello Anna,

      You can include several conditions in one formula the following way:
      =IF(B2="A","Good", IF(B2="B","Medium", IF(B2="C","Bad","")))

      You need to enter the formula in C2 and copy it down to apply it to the cells below as well.

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 :)