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

  1. @Adeel wait 2 min bro miss Svetlana already given me this formula.. let me share it with you

  2. hi Svetlana, thnx for your help but i need it again. please guide me to make this farmula.
    A1="UA" i want cell A1 to be color in red
    how it will work?

  3. I want to link a document so that if it is greater than today it =A4 and if it is less than today it =A3. Say the document with A3 and A4 is called pizza. What would this formula look like?

  4. I want to know the formula as per following data:

    F G H
    1 50 100 (I want if G1 value is less than 100 so F1 multiply with 10 but if G1 value is greater than 100 and less than 200 so F1 multiply with 20 and if G1 value is greater than 200 so F1 multiply with 30 and answer came in H1)

    kindly provide assistance

    1. Hi Adeel,

      Here's the formula for H1:

      =IF(G1<100, F1*10, IF(G1<200, F1*20, F1*30))

  5. Hi Svetlana Cheusheva,
    am just looking to put one formuls to calculate the tax value using IF function.the things are like follows....

    Suppose if there three columns f j and h
    if i enter the value in f as 5.5% then it should give me the value of the f*h in the column j

    ex: (in column j) =IFf=5.5% then it should calculate the value of f*h.
    could you plese help me out in this...

    1. Hi KIRAN,

      If you need a formula exactly for 5.5%, then enter the following one in cell J2:
      =IF(F2=5.5%, F2*H2, "")

      The above formula multiplies F2 by H2 if F2=5.5%, and returns an empty string otherwise.

      If you are looking for a more universal formula that multiplies a value in column H by whatever percentage you enter in column F in the same row, then use this one:

      =IF(F2<>"", F2*H2, "")

  6. Hi Svetland,

    I am using this formula to find out whether 2 values exists in a column, if it doesn't, I want the result to indidate "NO", if it does, then "YES". However, it shows us "FALSE" for those that does exist. Can you check what I did wrong?

    Thank you!

    =IF(ISERROR(VLOOKUP("AP1902"&TRIM($J51)&TRIM($Q51),$C:$C,1,0)),IF(ISERROR(VLOOKUP("A80201"&TRIM($J51)&TRIM($Q51),C:C,1,0)),"NO","YES"))

  7. Hi Svetland,
    Please help me write this IF formula correctly. i have a cell with different figures but some are missing data sets.
    i want a command that says IF F3>1 then the answer should be 1, IF F3<1 then it should be 0 but if F3 is empty (meaning there is no number there) it should be empty. meaning if F3 is empty, leave blank.
    Kindly assist.
    thank you

    1. Hi NASCO,

      You can use a nested IF formula like this:

      =IF(F3>1, 1, IF(F3<1, 0, ""))

      Please pay attention that the formula will also return an empty string if F3=1. So, you may probably want to add one more condition to the formula or replace F3>1 with F3>=1.

  8. Hi

    I am a total excel self taught newbie working on an Excel Workbook recording expenditure and wondered if there was an easy way to input the following in formula format:

    If a number is 50 to 100 minus 5% if a number is greater than 100 minus 10% in excel

    EG if the number in cell K20 is between 50.00 & 100.00 then 5% is deducted and if the number is 100.00 or more then 10% is deduced, I have managed to create a formula to deduct 5% if the number is 50.00 using the IF function =IF(K21>$M2,N2,)
    K21 = total
    M2 = 50.00
    N2 = % sum

    The above works fine however it is picking all amounts above 50.00 as I am unable to set the parameters so it only picks up amounts above 50.00 but less than 100.00

    Any suggestions?

    Many thanks

  9. What if I want more than one logical test in my formula?

    eg: If I want "IN TRANSIT" and "DISPATCHED" to be covered by one formula only.

    Awaiting Response

    1. Hi Aditya,

      You can do this by using nested IF functions, for example:

      =IF(A1="IN TRANSIT", value_if_true, IF(A1="DISPATCHED", value_if_true, [value_if_false]))

      1. Thank you so much. you were a great help.

  10. Hi,

    Thanks for above test eg.it lot me help to learn IF formula.

    Thanks.

  11. Hi,
    This is what I am trying do
    if value on A1 between
    0-154 A2 0
    155-462 A2 -1
    463-770 A2 -2
    771-1049 A2 -3

  12. thank u vry mch

  13. If i put red as value in one cell,what is the formula for appearing the same color in next cell

  14. how do you count if a column has two words like phone, mail
    and if a filter is applied at another column , the formula should count as per the filter applied not all the cells of the texts of the first column

  15. Hey so I have a file with 5 Columns and 5000 Rows, there is data in each row, some rows are in Times New Roman, others are in Ahora.

    I want to create a statement which basically says,

    IF X is in Times New Roman then its a Yes, If not then its a No....PLEASE HELP ME!!!

  16. Hi Svetlana,

    Can you please resolve the issue with my formula. I am trying to enter multiple logics with multiple values.

    =IF(D1>22,"This is a VERY HIGH risk study"), IF(D1>17,"This is a HIGH risk study"), IF(D1>12," This is a MEDIUM risk study"), IF(D1<=12,"This is a LOW risk study")

    Thanks

    1. Hi Jamil,

      When using nested IF's, all closing parentheses should be at the end of the formula, like this:

      =IF(D1>22,"This is a VERY HIGH risk study", IF(D1>17,"This is a HIGH risk study", IF(D1>12," This is a MEDIUM risk study", IF(D1<=12,"This is a LOW risk study"))))

      1. Thanks Svetlana, Works like a dream.

        BW

        J

  17. Respected Mam
    Actually we have some data base sheet in excel and we want to get a particular data from the sheet as we have "Ch. No. 000122 issued to Mr. Dilip I317018893 khargone(Cancelled)" in row and we want to get only "I317018893" form this data so please guide me the proper formula of excel so that I can easily do it.

    Thanks and regards
    Satish

  18. Hi Svetlana,

    i have this issue with my formula:

    D1 : due date
    E1 (value) : =NOW()-D1
    F1 : open or closed

    what i'm trying to do is, when i choose F1 as closed, i would like to have E1 value to be '0'. this is my formula which is still in error : =IF((NOW()-D1),(F1=Closed)),'0'.

    please help,thanks in advanced!

    1. i managed to find the error and fix the formula. Here is the fixed formula =IF(F1="Closed","0",NOW()-D1). =)

  19. how can i right a formula if i want result of that cell is equal or less than zero to return zero value?

    Thank you,

    Tien

    1. Hi Tien,

      You can use a formula similar to this:
      =IF(A1<=0, 0, "")

  20. I have two worksheet, in the first one it comes only one column with electronic component designators(example R3-resistor), in this column for each designator(resistor, capacitor or diode), corresponds a row. however in the other spreadsheet i have like more than one designator(the same designators as the first one) and it corresponded part number. what i want is a formula which compares designator and give me the part number in the first column. thank you

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

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

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

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

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

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

  27. 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!

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

  29. L10 12 , L1016

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  46. 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!

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

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

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

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

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