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

  1. PER GRADE GRADE points
    66.5 C
    80 B
    90 A
    65 D

    if A=4 ,B=3.5 ,C=3 ,D=2 HOW CALCUATE (FORMULA)

  2. hi I want to find a value if a1=less then 20 "80" more then 20 bt less then 40 then calculate(a1-20)*7)+80) bt a1 is greater then 40 then calculate (a1-40)*10)+230 please help me ma

  3. I have an if function question I can't seem to find a similar question in your article. For example Tenant lease start D12 and lease end dates E14; has to give me the date in G14. The same date that is in D12. This tell me when I can start doing improvements. How is the if function written out?

  4. Hii...

    I need a help, question is

    PF is 20% of Basic salary or Rs.1000 whichever is less

    Please give me answer as soon as possible.

  5. Hi I would like to ask how do I type in the formula box if for example I want it the multiplier to be like this:
    If the value ranges from:
    1 ~ 10 = 150
    10.1 ~ 50 = 120
    50.1 ~ 250 = 110
    251.0 ~ 500 = 100
    501.0 ~ 750 = 95
    751 ~ 1000 = 90

    If I have typed a value of 57, it should be 57 * 110 (since 57 is at range of 20.1 ~ 250 = 150 (150 as the multiplier))

    Please help.

    Thanks

  6. Thanks Svetlana
    I didn't see your reply but thank you for answering

  7. All is Ok, I have managed to solve the problem by using SUMIF.

  8. I have a column of repeated names and a column of values against the names say C2:C101 (names) and I2:I101 (values). I have tried to work out a formula that looks for one of the names in column C and gives a total of all corresponding values in column I.
    I have tried variations of =IF(C2-C101="Walker, David","SUMI2-I101","0") but I just cannot get it to work.
    Can you help please.
    Thank You

    1. Microsoft Excel has a special SUMIF function for this purpose, which makes the formula as simple as:

      =SUMIF(C2:C101, "Walker, David", I2:I101)

  9. Hi, looking to do the following:

    Cell C1 has mobile #
    Cell D1 has mobile # or is blank
    - we insert rows manually below each data entry which has values in C1 and D1 (throughout the sheet)
    - if there is an easier way, please advise

    I now want to have the value of the newly created row reflect the value of D1 if there is data in D1; but
    I want to be in a position to drag the formula through the whole sheet and there won't be rows inserted below data entries that doesn't have values in D1; thus
    I want those data entries to remain the same.

    My problem is that it creates a circular reference.

    Virgin sheet ex.

    A B C D
    1 Dave Scott 0845685841 0824865892
    2 Jill May 0725984287
    3 Jhon Snmit 0605493216 0915876431

    Manually insert row below person with 2 numbers
    A B C D
    1 Dave Scott 0845685841 0824865892
    2 xxx xxxxx xxxxxxxxxx xxxxxxxxxx
    3 Jill May 0725984287
    4 Jhon Snmit 0605493216 0915876431
    4 xxx xxxxx xxxxxxxxxx xxxxxxxxxx

    Thus I want to be able to do the following:
    Input a formula in column C to display the value of D in the above row or remain the same if D is blank

    What I tried, but gave me circular reference:
    In C2 =IF(D1"",D1,C2)

    The same will apply to the names, will also want to be able to populate the persons name in the newly created row for their second number:

    In A2 =IF(D1"",A1,A2)

    The result that we are looking for is:
    A B C D
    1 Dave Scott 0845685841 0824865892
    2 Dave Scott 0824865892 xxxxxxxxxx
    3 Jill May 0725984287
    4 Jhon Snmit 0605493216 0915876431
    4 Jhon Snmit 0915876431 xxxxxxxxxx

    Therein lies my problem, kindly advise

  10. I am trying to design a function to produce a "grade" based on a number of columns.

    There are three possible grades given: UNSAT, SAT, SUP

    There are eight graded sections(columns), each with one of the given grades above.

    I want the ninth section to produce an OVERALL grade based on the previous grades.

    SUP on 7 or 8 of the previous eight grades (columns)
    UNSAT on 2 or more of the previous eight grades (columns)
    SAT in all other cases.

    Thanks for any help you can provide!

    1. Never mind! I found the answer by using a mixture of IF and COUNTIFS Functions:

      =IF(COUNTIF(A24:G24,"SUP")<7,"SAT","SUP")

      This answer actually nullifies the requirement to have an UNSAT answer in the field, only because it was easier for me to count an UNSAT manually vice work the multitude of function. If i do find a better answer (to my own question haha) I will update it!

  11. THANK YOU Svetlana, this was exactly the help I needed!

  12. Oh, Svetlana! I am forever indebted to you!!! THANK YOU so very much for the formula! It worked perfectly!! I cannot tell you how grateful I am for your help!

  13. Oh, dear! Can anyone please help?!?

    I have been working on finding a formula to work in a spreadsheet and can't find the correct one to produce the results I need.

    I want to say: IF C6=X,or C7=X, or C8=X, or C9=X, or C10=X, or C11=X, or C12=X, or C13=X, THEN C4=X.

    Every time I try using an IF statement or an OR statement, it doesn't work properly and it says my formula is broken.

    Does anyone know what the correct formula would be for this? I have spent hours using tutorials and working out formulas but still can't get this to work. ANY help would be greatly appreciated!!

    1. Hi Julie,

      Try entering one of the following formulas in cell C4.

      If X is a text value:

      =IF(OR(C6="X", C7="X", C8="X", C9="X", C10="X", C11="X", C12="X", C13="X"), "X", "")

      If X is a number, say 1:

      =IF(OR(C6=1, C7=1, C8=1, C9=1, C10=1, C11=1, C12=1, C13=1), 1, "")

  14. Hi Svetlana,

    I have two problems I can't solve. I hope you can help me!

    I have a value in Column D. I want to subtract that value from 20. If the result is 0 or less, I want Column J to show 0. If the result of 20-D is greater than 0, I want to display that value.

    For example:

    The value in D4 is 22, 20-22 = -2, therefore J4 shows "0".
    The value in D4 is 14, 20-14 = 6, therefore J4 shows "6".

    Here is the formula I have in Column J: IF(SUM(20-D4)=0,),"0",(SUM(20-D4)

    It doesn't work.

    Also, I have a value in Column F. If the value in Column F4 is equal to 100, then Column L4 should show 5. If the value in Column F4 is between 90 and 99, Column L4 should show 4. If Column F4 is between 80 and 89, Column L4 should show 3. If the value in Column F4 is between 70 and 79, Column L4 should show 2. If Column F4 is between 60 and 69, Column L4 should show 1. If the value in Column F4 is equal to or less than 59, Column L4 should show 0.

    For example: The value in Column F4 is 87, therefore Column L4 shows "3".

    I don't understand how to write this formula either. I am new to formulas in Excel and I don't understand the syntax.

    1. Hi Kathleen,

      Here is the first formula:

      =IF(20-D4<=0, 0, 20-D4)

      As for the second task, you need nested IF's here:
      =IF(F4=100, 5, IF(F4>=90, 4, IF(F4>=80, 3, IF(F4>=70, 2, IF(F4>=60, 1, 0)))))

      I hope these are the formulas you are after :)

  15. dear all

    please clear the following detail.....

    stock Value RATE physical
    44 1872 43 44

    if physical and stock is equecl print the value 0 and physical value 45 into the rate value and physical value 43 into the rate, so clear the urgent basis.

    regard

  16. If A1 in sheet1 contains "AAB00001-A3" and A5 has 45
    A2 in sheet1 contains "AAB00001-A4" and A5 has 54

    I want add 45 with 54 using IF function Comparing A1 and A2 with "AAB00001" which is there in other sheet and cell.

    Please help.

  17. I wanted to use if function of changing last digit of 3 digit number.
    example: 102, 103, 104, 105, 106
    2 is admin
    3 is HR
    4 is Finance
    5 is research
    6 is field staff

  18. Hi Ms. Svetlana,

    Can you help me on this?

    IF today's date, range from 1 to 15; my date input should be mm/15/yyyy in a cell.
    But IF 16 - 31; date input should be mm/30/yyyy.

    I have formula but not working properly:
    =IF(DATE(YEAR(TODAY()),MONTH(TODAY()), TODAY())>15, DATE(YEAR(TODAY()),MONTH(TODAY()),30), DATE(YEAR(TODAY()),MONTH(TODAY()),15))

    Hope you can help.

    Many Thanks!

    1. Hi Gibson,

      Try this one:

      =IF(DAY(TODAY())<15,DATE(YEAR(TODAY()), MONTH(TODAY()), 15), DATE(YEAR(TODAY()),MONTH(TODAY()),30))

      1. Whoa! Thanks for the response. Many Thanks! :)

        Btw, do you have any eBook I can buy?

        1. All I have is the articles published here on ablebits. But thanks for the idea :)

  19. I want to add the value of certain cells only if the value = 1.
    I have a list of guests to attend an event; I conditioned the cells so if they are attending and I type a 1 the cell goes green, 2= RSVP TBD and cell goes yello and 3= not attending and cell goes red.
    I want to know the TOTAL number of guests attending (I will have to add all the cells if the value = 1)
    I tried:
    =IF(C3:C18=1, SUM(C3:C18)) but that returns the addition of all the numbers in that range of cells, regardless if they are 1, 2 or 3)
    THANKS!

    1. Hi Manolo,

      All you need is a simple SUMIF formula like this:
      =SUMIF(C3:C18, 1)

      For more info, please check out our Excel SUMIF tutorial.

  20. Hi Svetlana

    Im trying to make a dynamic sheet for car configurations according to track and weather conditions, not sure if possible specially if they are around 30 tracks or is limited to X number of tracks. The idea is like this

    A1= Track01, Track02, Track03, Track04, etc......
    B1= Dry, Wet

    C1= IF((A1="Track01" and B1="Dry";1;3)(A1="Track02" and B1="Dry";2;4)(A1="Track03" and B1="Dry";3;9)(A1="Track04" and B1="Dry";4;12)) etc.....

    Thanks in advanced :)

    1. Hi Ernesto,

      You can express all of your conditions using nested IF's and AND. For example:

      =IF(AND(A1="Track01", B1="Dry"); 1; IF(AND(A1="Track01", B1="Wet"); 3; IF(AND(A1="Track02", B1="Dry"); 2; "")))

      1. Works at perfection, thanks :)

  21. i want to make a mark sheet with result of different students, i want result fail if value=<34, then what will be the arguement, how can i write the cell range in formula. i have done it, but it is wrong! plz help

  22. hi svetlana
    i am working as a planning officer in textile. i have to make/maintain multiple sheet. can you help me?

    imran

  23. Hi..I am currently working on sales report and using IF formula. However I encountered IF error message - "IF only takes 3 arguments but this is argument number 4". Appreciate your help on this....thank you

    1. Hi Alynda,

      Yes, the syntax of the IF function allows for 3 arguments only. You can find the detailed explanation of each argument at the beginning of this article. If you provide more details about your formula, we will try to get it right.

  24. Using the data in C16:C18, generate in Cell E16 the formulation that will check Cell C16 for a Y, an N or any other character and if this cell contains a Y the formulation will round the figure in Cell C18 (19.2589) to the number of decimals indicated in Cell C17 (3), if Cell C16 contains an N the formulation will not round the figure in Cell C18 and simply return the number that is in Cell C18 and if Cell C16 contains any other character, the formulation will return the error message “Invalid Character”.

    Would this be an IF function?

  25. if value entered B 1 40 to 45 the value C 2 36 and if enter 46 to 50 , the value C 2 37

    1. Here is the formula for C2:

      =IF(AND(B1>=40, B1<=45), 36, IF(AND(B1>=46, B1<=50), 37, ""))

  26. A B
    10 0
    Please help, B=A"Paid", B=0"Outstanding" and 0<B<A"Pending" Thank you!

    1. Hi Kea,

      Here you go:

      =IF(B1=A1,"paid", IF(B1=0,"Outstanding", IF(AND(B1>0, B1<A1),"Pending", "")))

      1. Hi Svetlana, I working well thank you again for your help and sorry for late checking

  27. Hello,

    I have the following formula so far:

    =IF(A1>=40,"40",""), If the value is less than 40 I need the result to be the exact value in the cell.

    For example if A1= 39.5 I need the result to be 39.5 not blank as I currently have it in the formula. What can I replace "" with to get this result?

    Thank you!

    1. Hi Olga,

      Just replace "" with the cell reference, like this:

      =IF(A1>=40, 40, A1)

  28. Dear Svetlana Cheusheva

    Is this formula correct

    =IF(H2="#N/A", "No", "Yes")

    where #N/A is a result of vlookup which is applied in H2

    1. Please help i am stuck here

      1. Hi Khan,

        You have to use the ISNA function to check another cell for N/A error, like this:
        =IF(ISNA(H2), "No", "Yes")

        1. Thanks Svetlana, I was using ISNA but wrong, this helped.

        2. Really v thankful to you it worked

  29. Hi can you help me formulate one formula for these situations:

    1. If the actual completion date (F9) is less than or equal to the target completion date (E9) then it's ON TIME
    2. If the actual completion date (F9) is greater than the target completion date (E9) then it's OVERDUE
    3. If the target completion date (E9) is greater than the date today (B5) and the actual completion date (F9) is unfilled it's NOT YET DUE
    4. If the target completion date (E9) is less than or equal the date today (B5)and the actual completion date is unfilled it's UNDONE

    My formula I have right now is:
    "IF(F9E9,"OVERDUE",IF(E9>B5,F9="","NOT YET DUE",IF(E9<B5,F9="","UNDONE"))))
    But it says I'VE ENTERED SO MANY ARGUMENTS

    Thanks!

    1. Hi Tetay,

      You have to use the AND function when entering more than 1 condition, like this:

      =IF(F9<=E9, "ON TIME", IF(F9>E9, "OVERDUE", IF(AND(E9>B5,F9=""),"NOT YET DUE", IF(AND(E9<=B5,F9=""), "UNDONE", ""))))

      1. Thanks but it does not work for the NOT YET DUE and UNDONE. I think there is something missing?

        1. Because it still displays ON TIME even if the actual completion date (F9) is unfilled.

          1. Oops... I forgot to check if F9 is not empty in "ON TIME" and "OVERDUE" logical tests.

            Please try this one:

            =IF(AND(F9<=E9, F9<>""), "ON TIME", IF(AND(F9>E9, F9<>""), "OVERDUE", IF(AND(E9>B5,F9=""),"NOT YET DUE", IF(AND(E9<=B5,F9=""), "UNDONE", ""))))

            1. OMG Svetlana! Thank you so much, it's working. YOU'RE AWESOME

  30. Please help me providing with encoding stating Week 1 Week 2 Week 3 Week 4 so on for the Year, to come automatically depending on Date in other cell.

  31. how to create a subscript in an "if()" function? for example if(1<2,"FS","") the "S" should be in subscript. thank you!

  32. I want to replace F2 with value in G2 if value in F2 is 0.

    1. Rukia,

      It is not possible to have a value and a formula in the same cell.

  33. Hi There,
    I use this formula but nothing is coming out:
    =IF(B6>2),"3.86"
    what i need is if b6 is > 2 i need excel to put 3.86 and 3.99 if b6 is <= 2
    Thanks

    1. Hi Teame,

      Please try this one:

      =IF(B6>2, 3.86, 3.99)

      1. Mant Thanks Sve.

  34. I need help figuring out 2 calculations

    1.If cell is blank, then leave cell blank, but if cell has a value then add another cell.

    2.Total cells and then divide by cells that only have value. Example if there are 10 cells, but only 5 have value, you would divide by 5.

    1. Hi Toni ,

      You can use formulas like these:

      1. =IF(A1="", "", B1)

      A1 is the cell you check for being blank/non-blank, and B1 is the cell you add if A1 is blank.

      2. =SUM(A1:A100)/COUNTIF(A1:A100, "<>"&"")

  35. Hi,

    I am currently working with a schedule, and I am trying to make an IF function that if I have a table that will show me who is working each shift, it will look at the schedule and pull the person that is scheduled at a certain time.

    An Example:
    If I have person A scheduled at 11:15 AM and I want there name to be pulled into the table which shows all the employees that work at 11:15 AM how would I do so. Currently the function I am trying to use (=IF(B13="11:15 AM", A13) is not working. B13 is representing the starting time of the shift, while A13 is representing the Employee name. I would greatly appreciate any help you can give on this matter, thank you!

    1. Hi Phillip,

      When comparing dates or times in Excel, you have to use the DATEVALUE and TIMEVALUE functions, respectively, in order to convert a date or time unit in the text format to a serial number that Excel recognizes as a date / time. For example:

      =IF(B13=TIMEVALUE("11:15 AM"), A13, "")

  36. What is the formula when my conditions are;

    If 0<= A < 10 the result is 3
    If 10< A < 15 the result is 2
    If 15 < A 20 the result is 0

    Assuming that the variable A is the value on a certain cell.

    Thanks

    1. Forgot to mention;

      if 15< A < 20 the result is 1

      1. Hi Faith,

        Here you go:

        =IF(AND(A1>=0, A1<10), 3, IF(AND(A1>=10, A1<15), 2, IF(AND(A1>=15, A1<20), 1, "")))

  37. Thank you for the article. I don't know if there is a function to do what I want, but here is basically what I am looking for.

    I have a list of items that I have set to display on a different sheet. I would like a large number of those items (those that start with a 4) to be combined into one cell with a different name in the same list (The 400 Series). Is there a function that will keep my list intact, but combine all the names that start with 4 into my new cell? I don't need a count of them by the way, just the list to transpose itself over as it is now with those specific cells pushed down into one.

    Thank you for the help.

    1. As a follow up and to complicate my question, I am hoping to establish a function to do this dynamically every day when I import new information. If I were doing it only once, I think I could just remove the "4" items and put in a new block, but this would become a timely process if I were doing it every day, because I have the list being dynamically generated, which would bring back all my "4" blocks with the new import each day.

      1. Can I assume my question is too complicated?

  38. Hi Svetlana,

    I need to create the following if statement.

    IF the member type in B6 = "TC" then take the date from B3 and + 10 Days, If the member type in B6 = "T2C" then take the date from B3 and + 15 Days.

    1. Hi Adam,

      Here you go:
      =IF(B6="TC", B3+6, IF(B6="T2C", B3+15, ""))

      Please remember to change the format of the cell with the formula to the Date format so that is displays the date correctly.

  39. Hi Svetlana

    I would like to create in "IF" statement or an "ISBLANK" statement that says that if C2 is blank, populate from D2. If C2 has text, do nothing.

    =IF(C2 is Blank, Populate from D2) or =IF(ISBLANK(C2)=TRUE,D2,0)

    Thank you!

    1. Hello Donni,

      You can use either of the below formulas:

      =IF(C2="", D2, "")

      If cell C2 is "visually blank" (including an empty string returned by some other formula, if any), the formula returns a values from D2, otherwise returns an empty string.

      =IF(ISBLANK(C2), D2, "")

      The second formula returns a value from D2 if cell C2 is absolutely blank (no value, no empty string).

      Please see the Excel IF examples for blank, non-blank cells section in this tutorial for full details.

  40. Hi,

    I have a formula that is returning "Recent" in cells that do not contain dates.

    =IF(C6>DATEVALUE("4/21/2014"),"Recent","")

    Cell C6 = "1 File(s)"

    What can I do to exclude cells that do not have dates?

    1. Never mind this, got it figured out.

  41. Hi,can you help me with formula if for this condition, if F3=A,D3=1,the result for H3=C3 & if F3=A,D3>1 the result for H3=-1 in 1 formula if. Thank you :)

    1. Hi Pichan,

      Here is the formula for H3 as per your conditions. If nether condition is met, it will return a blank cell (empty string).

      =IF(AND(F3="A", D3=1), C3, IF(AND(F3="A", D3>1), -1, ""))

  42. Hi, im trying to place a formula that, according to a "word" I can get a number as true or false value.
    ex.: A1= Casa .......... B1= If=(A1Casa,"2","5"), something like that.

    Thanks in advanced. :)

    1. Hi Roman,

      I believe you meant =IF(A1="Casa", 2, 5)

      1. Yes,sorry...... but I get a warning that I shoud put an apostrophe, but is possible to make work somehow?

        1. Most likely this is because you have ";" set as a List separator (you can check this in the Regional settings). If this is the case, then try =IF(A1="Casa"; 2; 5)

          1. Sweeeeet, perfect, thanks Svetlana :)

            1. Sorry again, work at prefection, but something else that I want to know if possible, Is possible also to make a Image to show in a cell linked to a word in a formula?, if possible can you direct me to a link of how to do it?, thanks again :)

  43. =(D3/B3)if(B3="0"),D3,E3 I get error please help
    D3=hour B3=Sales E3=final number

    1. Hi Daniel,

      Sorry, I cannot follow you. Can you explain the condition (logical test), please?

  44. Hi Clarence,

    Here you go:
    =IF(AND(E20<J21, E20<D21), MAX(F11:F15), "")

    1. it's not working :'(

  45. hi , can you help with my sheet ? I can't translate it to codes in excel .this is how i read it "if e20 is less than j21 and d21 , i should get the cell with the highest value in f11 to f15 cells . thanks .

  46. HELP! :( Working on a sheet I have made a drop down in a cel and I would like the cel next to it to enter text if a certain word is selected in the drop down, is this possible?!?! I am not very good at explaining so I can try my best with whatever questions you have!

    1. For example, if the drop down menu is selected Oranges I want cel G to now have Bananas in it, but if from the drop down Grapes is selected I want cel G to now say Grapes, and so on and so on, honestly have 27 so far in the drop down and need an IF in G if something is in the drop down menu, is this possible?!?!

      1. Hi Ryan,

        If you want a cell next to your drop down list to display the same value as currently selected in the drop-down, all you need is a simple formula like =$A$1 where A1 is the drop-down cell.

        If you want to display different values, then you should use nested IF functions, like this:

        =IF(A1="bananas", "bananas2", IF(A1="oranges", "oranges2", IF(A1="grapes", "grapes2")))

  47. =IF(AH5>69, AG5*5, IF(AH5>59, AG5*4,IF(AH5>49, AG5*3,IF(AH5>44, AG5*2,IF(AH5>39, AG5*1,IF(AH569) and so on.
    pls, can you help

    1. Hi Fred,

      The formula looks good. You just need to finish it properly, by closing all IF statements. I.e. the number of closing brackets should match the number of opening ones. Also, in the value_if_false argument of the last IF, enter the value to display when none of the conditions are met - it's an empty string ("") in the example below:

      =IF(AH5>69, AG5*5, IF(AH5>59, AG5*4, IF(AH5>49, AG5*3, IF(AH5>44, AG5*2, IF(AH5>39, AG5*1, IF(AH5>29, AG5, ""))))))

  48. Hi! I am trying to use an IF Formula to provide me a date result.

    =IF(H2=S, [Approval]+(7*[Estimated weeks from Start to Approval]),IF(H2=P, [Start]+(7*[Estimated weeks from Start to Approval])))

    I'm not sure what to enter at the end for the result to show a date.

    Thanks!

  49. Thank you Svetlana!!!

  50. Hi Svetlana, It would be great if you could help, I think I'm nearly there but getting frustrated :)

    =IF(AND((E4-AG4>=5),50,0),IF(AND(E4-AG4<=-5),50,0))

    I'm building a sports sheet, whereby E4 is the actual spread and AG4 is the predicted spread. If the predicted spread is within +5 0r -5 then 50 points are awarded.

    Appreciate your help
    Kind regards
    Barry

    1. Hi Barry,

      The correct syntax of your formula is as follows:
      =IF(AND(E4-AG4<=5, E4-AG4>=-5), 50, 0)

      And you can make it even more simpler by using the ABS function that returns an absolute value regardless of the sign:

      =IF(ABS(E4-AG4)<=5, 50, 0)

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