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

  1. Hi,

    I am trying to use IF function with multiple conditions but I am not getting the results I want to. Some times it works on one or two values but as I change the values to validate the formula it start making wrong outputs.
    So far I made this formula;

    =IF(C7>=70,"In Range",IF(C7<=100,"In Range",IF(C7<=69,"Low Alkalinity",IF(C7<=59," Too Low Alkalinity Can damage Plaster, Vinyle, Grouting etc",IF(C7<=49,"Danger Zone can't control pH levels",IF(C7=110,"Scaling can happen any time",IF(C7>=150,"HIGH Alkalinity",IF(C7>=200,"Pool equipment damaging",IF(C7>=250,"Stop Bathing in Pool HIGHLY DANGEROUS"))))))))))

    safe range is between 70ppm to 100ppm and I am trying to get remarks according to findings if findings are getting as low as 70 it should show relative comment in remarks column and if finding are more than 100 it should show accordingly or else if its in range it should say "In Range" in Remarks... Please some one help I need this one. Thanks in advance .....

  2. 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?

    1. 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?

  3. I AM TRYING TO GET A CATEGORY LIKE FOLLOWING.
    123 42 HR
    456 52 MR
    258 50 HR
    159 55 MR
    756 70 LR

    HELP TO SOLVE

  4. 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

  5. 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?

    1. 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?

  6. 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

  7. A B C D E
    1 Date 3X5.5 6X5.5
    2 03-23 6X5.5 345 345
    3 03-24 3X5.5 580 580

    please help, thanks!

  8. I have work with formulas previously but I need to get this formula correct:

    =IF(K2"",K2,IF(AND(L2="",I2="Regional"),DATE(2015,5,29),""))

    How to write a nested if from above when :

    I2=Panama date(2015,7,29)
    I2= Singapore date(2015,6,8)
    I2= UK date(2015,10,8)
    I2= Mexico date(2015,6,10)
    I2=Italy date(2015,11,22)

    Thank you for your help

  9. L10 12 , L1016

  10. 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.

    1. =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)))

      1. =SUM(IF(AND(J1012),IF(AND(J1016)IF(AND(J1112)IF(AND(J1116),

        1. 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.

  11. 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

    1. 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

      1. Thank you!! this is exactly what I was looking for.

  12. i need a column to change based on the choice chosen from a drop down menu in another column.

  13. I hv worked out some formulas but need to get it right. I have data on the above 5 cells (a5 to a9) and in texts-company names.
    I have values at the bottom cells (b5 to b9). i have to get the lowest value in b5 to b9 and it is $1. it is found under company XXX iof cell a7 and is b7. Now i have to put the company name next to cell b11 because cell b10 is value of comp XXX in cell a7. for example, after i am thru entering values from b5 to b9 cell b10 will hav $1 while b11 should have company name XXX in it.
    Pls help me on this project.

  14. Currently I have a formula:
    =If(k2"",k2,if(l2="",(date92015,5,29)l2
    Need to add one more field = I2, that contains these five values
    Regional or
    Panama or
    Costa Rica or
    Colombia or
    Singapore
    based on these 5 fields date will be dirrent
    Please advise of how to handle these additions

  15. Currently I have a formula:
    =If(k2"",k2,if(l2="",date92015,5,29)l2

    Need to add one more field = I2, that contains these five values
    Regional or
    Panama or
    Costa Rica or
    Colombia or
    Singapore
    Please advise of how to handle these additions

  16. 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)

    1. 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)

  17. 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"))

    1. 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", "")))

      1. Thank you so much!

  18. 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

    1. 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,""))))

      1. thank you so much!!

  19. how about i need something less than 50 turn into yellow color word, less than 0 turn into red color word.

    Is that possible?

    1. 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.

  20. 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.

    1. 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.

  21. hi Svetlana Cheusheva,
    can you please guide me to make a farmula for this calculation
    IF A16 and 9 and <12 than * 450
    hope you understand what i want in result like i need to multipuly the B1 with 150 if A1 is less than 6 and if it is more than 6 and less than 9 than with 300 and if A1 is more than 9 and less than 12 than multiply B1 with 450 and if A1 is more than 12 than multiply B1 with 600
    please rply ASAP

    1. Hi Sharfi,

      Here you go:

      =IF(A1<6,B1*150,IF(A1<9,B1*300, IF(A1<12, B1*450, B1*600)))

  22. Hi,
    Cani use If function for different criteria,actually i want to do ageing of invoices i want to know since how many days the invoice is pending outstanding.There are different no of days for each invoice i want to know the days bracket. i want the formulae as per below for eg.If cell A1306090,"90-days"

  23. Hi,
    I wanted to know how to do the below scenario in Excel using if function eg
    I have mentioned no. of days worked in a month cell(K1) and no. of working days in month another cell (J1),if K1<j1 then there is value mentioned in I1 which is got using this formula =ROUND(L3*12/100,0) or else 1560

  24. 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)

  25. 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

    1. Hi Matt,

      Try this one:

      =IF(COUNTIF(A2:D2, "plant")>0, "yes", "")

      1. Hi Svetlana,

        Worked perfectly.

        Thank you,
        Matt

  26. I found another way to find my average % completed:
    =IF(O5>0,(SUMIF(F9:F15,"Active",I9:I15)/O5),"100%") where O5 equals total active students. This one stumped me when there were no active students. That is O5 is zero. Anyway, it works!

  27. I want to use IF to discriminate between individual turtles! I have drop downmenus describing each shell segment, e.g. box A segment one has a mark/ is white, box B the mark is single/double, Box C it is shaped like a circle, square, line, cone, other..then this combination of shell segment descriptions means the turtle is number 32. (All turtles have individual markings)
    How can I use if to return a specific individual identifier, rather than a yes/no, true/false answer?
    thanks for your comments in advance

  28. Hi Svetlana
    =IF(A1="Active",AVERAGE(B1),0)
    The above formula works for one cell, of course, but I need to construct it to work for a range of cells.
    If "Active" appears in column A,(A1:A9), then I need to calculate the average of all numbers in corresponding cells in column B, (B1:B9). Do I need to nest a VLOOKUP into this IF statement? Either way, can you please help?
    Many thanks :)

  29. 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?

    1. Hi Marlene,

      You can use a formula similar to this:
      =IF(ISNUMBER(A1)=TRUE, A1+100, A1)

  30. 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

    1. 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), "")

  31. 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

    1. 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)

  32. 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.

    1. 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, ""))

  33. Hi,

    i want a formula that will not show data on another workbook if the column is blank eg

    yes no
    \
    \
    \
    \
    \
    \

    i only want it to show the yes column on another tab but dont want any space between the date. Is this even possible using this function? I know its possible from using filter but dont want to do this

  34. 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.

    1. Hi Anwaar,

      You can use a nested IF formula like this:
      =IF(F31=0, H12, IF(F31>0, F32, ""))

      1. Thanks a lot!☺

        1. 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

  35. Hi Svetlana,

    I'm having difficulty with making a formula.

    What I want, is that if A1 is not Blank, that C1 Prints "N/A", but if C1 is not Blank, then B1 and A1 Print "N/A".

    I currently have: =IF(NOT(C1=""),AND(A1="N/A",B1="N/A"),IF(NOT(A1=""),C1="N/A","Error"))

    (If not possible please let me know as I've been having trouble with these recently, thanks)

  36. Hi,

    I need to compare the data between two xls sheets(cell to cell validation).

  37. 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

    1. Hi Ross,

      Just use the DATEVALUE function in the logical test:

      =IF(D7<=DATEVALUE("1/2/2015"),"A","B")

  38. 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.

    1. 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.

  39. I am trying to change a formula from =IF(H2="2-bdrm/2-bth",$K$3,IF(H2="2-bdrm/1-bth",$K$4,IF(H2="1-bdrm/1-bth",$K$5,))) which determined the average rental price to a formula that determines the what the highest rental price is for each size apartment. Anyone that can help I would greatly appreciate?

  40. sorry it's not working

    1. 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)

  41. Hello,
    i want to make one condition like
    party payment days are going between 70 days so that's mention in excle
    inv. date amount 30-60 days ,60-90 days, above 90 days
    1 1/4/15 50000 0 50000 0
    pls give me that type of formula ,
    i use one formula =if(now()-datevalue(b1)<30,+c1,0) but it's now working
    pls give me other formula

  42. 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

    1. Hi Janay,

      Here you go:

      =IF(C10=0, "", C10*$D$7)

  43. 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.

    1. 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)

  44. hi, how to do this, ex:
    22.7 auto increment to 23 or 22.3 to 22 ?
    if 22.5 till 22.9 to be 23 or 22.1 to 22.4 to 22 ?

    1. Hi,

      Use this formula, your data in a column

      =ROUND(A1,0)

  45. Hello, Excel will not accept the following formula:
    =IF(F3= "yes", [G3*1.1], [G3])

    All I want it to do is return Cell G3 x 1.1 if cell F3 = Yes, else just cell G3. What is wrong with my format?

    1. Hi Paul,

      Just remove square brackets:

      =IF(F3= "yes", G3*1.1, G3)

  46. Hello

    I am trying to work out a formula for a table of rental charges for rooms in a house.

    Column E is 'date from' and Column F is 'date to' and column H is number of days. Rent runs from the 19th of each month.

    I used the following formula to work out rent cost for the number of days they were there which is basically saying

    'if the 'to date' is 19/05/15 then return the monthly rental value as shown in cell C14, but if it is not 19/05/15 then use the number of days multiplied by the daily rental value to give me an amount'

    =+IF(F4=DATEVALUE("19/05/2015"),C$14,0)+IF(F4DATEVALUE("19/05/2015"),(H4*E$14),0)

    I realised though that this only works if the month starts on 19/04/15. I have one tenant that moved in on 08/05/15 and i therefore need to adjust the formula to say that if column F= 19/05/15 and column E=19/04/15 then return the monthly rent but if F doesnt equal 19/05/15 and e doesnt equal 19/04/15 then use the number of days multiplied by the daily rent.

    Is this possible as when i adjust the formula with an AND it comes back as invalid.

    Any help would be very much appreciated!

    Thanks in advance

    1. Hi Amanda,

      Just add the following AND statement in the logical test of both IF functions:

      =IF(AND(F4=DATEVALUE("19/05/2015"), E4=DATEVALUE("19/04/2015")), C$14, 0) +
      IF(AND(F4=DATEVALUE("19/05/2015"), E4=DATEVALUE("19/04/2015")), H4*E$14, 0)

      1. Many thanks Svetlana!

  47. Hi I am new to Excel and i am trying to format a mailing list that has been sent to me. basically the query is
    if f2 is blank then copy the contents from E2 into F2. blanking out E2 when done. i hope that is clear any help would be appreciated.

    Thanks

  48. assit me with nested if statement of a traffic robot set up with out come or result of GO,Stop and prepare to stop.

  49. hi, i am currently trying to generate a dashboard for my company and am having trouble inserting data into particular categories. there is a general data input sheet and then the dashboard. on the dashboard there are 3 separate categories with about a dozen free rows beneath for data to be inserted. i wish to insert data from the general data input section based on value of dates given etc. eg if the date is now then insert under category 1 if more than 2 years away, category 2 etc. could you please suggest any ways that i can do this the easy way etc, I'm trying to avoid inserting the data manually under each separate category as there will be a lot to enter. thanks in advance (:

  50. I figured it out in case anyone ever has the same question :-)

    =If(ISERROR(MATCH(B1,A1:A1,0)),"False","True")

    Thanks!

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