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

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

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

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

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

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

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

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

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

  9. 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 (:

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

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

    Thanks!

  11. There are also hundreds of different names in my data so Column B will not always be the same length. :)

  12. Column B
    Doejj
    Doejj
    Doejj
    Doejj
    Doejj
    Doejj
    Doejj
    Doejj
    Doejj

  13. If Column A contains Column B then Yes if not then No

    Can the formula take into account the case sensitivity as well?

    Column A Column B

    \\CCBF0FP21\DCLabels Doejj
    \\CCBF0FP21\DCLabels$ Doejj
    \\CCBF0FP21\DCReports$ Doejj
    \\CCBF0FP21\Direct$ Doejj
    \\CCBF0FP21\Review$ Doejj
    \\CCBF0FP21\DEV$ Doejj
    \\CCBF0FP21\Shipto Doejj
    \\CCBF0FP21\shipto$ Doejj
    \\CCBF0UD2A\UD1$\DOEJJ Doejj

    1. Sorry - the sample data on here is not displaying as 2 columns. To clarify:
      Column A
      \\CCBF0FP21\DCLabels
      \\CCBF0FP21\DCLabels$
      \\CCBF0FP21\DCReports$
      \\CCBF0FP21\Direct$
      \\CCBF0FP21\Review$
      \\CCBF0FP21\DEV$
      \\CCBF0FP21\Shipto
      \\CCBF0FP21\shipto$
      \\CCBF0UD2A\UD1$\DOEJJ

    2. Please Help :)

  14. Hi Tiffani,

    Supposing your dates are in column A, you can put the following formula in the "per diem" box:

    =IF(A1<>"", 20, "")

    The formula will return 20 if cell A1 in not empty. To format the returned number as currency, select the cell with the formula, press Ctrl+1 to open the Format Cell dialog, select "Currency" on the Number tab and choose the currency format you want.

  15. Please help me!

    For my job, I work a lot in excel. I have a spreadsheet to calculate per diem for drivers to receive on their paychecks. I have seven blank "date" cells. I'm wanting an if/then function so that if I write a date in one of the blank date boxes, it will automatically put $20.00 in the corresponding "per diem" box. Likewise, if the date box remains blank, the per diem box remains blank.

    Please help.

  16. Hi,

    I made a table for a high, medium,low with corresponding digits.
    Like for example,if the probability of failure is 1(rare) and the impact rating is low, then the result should be low.
    Now, my problem is how do i connect the table to my another sheet.

    please help

    1. try vlookup

  17. i have to do this in excel ,guyz help
    if b=250 value is 15
    if b=260 value is 12

    1. Hi Ajay,

      Here you go:

      =IF(B1=250, 15, IF(B1=260, 12, ""))

  18. I have my fantasy baseball spreadsheets. There are in two different files. File 1 has all of my palyers noted in column A and their positions in column B.

    I am looking to transfer the Info from Lets say "biils Row C" column A and B in my master file to "bills Row C" A and B in the updated spread sheet. I have the following formula that works on one line. but how do I get it to search the entire master sheet and pull that data over. The first C3 file is my updated sheet

    =IF(C3='[RE-ENTRY AS OF 5-5-15.xlsx]Hitting'!C3:C500,'[RE-ENTRY AS OF 5-5-15.xlsx]Hitting'!B3)

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

  20. Please advise how to use below formula in excel

    =if(L2>60,"Active"),if(L2<60,"Critical"),if(L2<0,"Overdue")

    1. Hi Vinath,

      You'd rather put it like this:

      =IF(L2>60,"Active", IF(L2<0,"Overdue", IF(L2<60,"Critical", "")))

      Just pay attention, please, that the formula returns an empty string if none of the conditions is met, e.g. if L2=60.

  21. I need help with a formula using dates:
    What I am trying to accomplish is if cell G2< 7/1/14 then insert 7/1/14 but if not insert the date that is in G2.
    =IF(G2<DATEVALUE("7/1/2014"),"7/1/2014",G2)

    Thanks for any help,

    1. Hi Monica,

      Your formula is correct. If it returns a serial number rather than a date, you should simply apply the Date format to the cell (press Ctrl+1 to open the Format Cell dialog and select the Date format you want).

  22. Can you help me with this formula:

    =IF(AND(AE303="",AK303=""),Incident),IF(AND(AE303""),AK303="",(NOW()-(AE303))),(DATEDIF(AE303,AK303,"D")))

    I am trying to have the formula:
    (1) if cell AE303 and AK303 are both blank put in the word "Incident", but
    (2) if cell AE303 has a date in the cell and AK303 is blank insert number of days between AE303 and Today, but
    (3)if both cells have dates, subtract them and tell me the # of days between

    1. Hi Lana,

      Try this formula:

      =IF(AND(AE303="",AK303=""), "Incident", IF(AND(AE303<>"",AK303=""), TODAY()-AE303, IF(AND(AE303<>"", AK303<>""), DATEDIF(AE303,AK303,"D"))))

      Just keep in mind please that DATEDIF requires the start date (AE303) to be always less than the end date (AK303), otherwise a formula will return the NUM! error. An easy workaround is simply subtracting one date from the other in the last value_if_false argument:
      AK303-AE303

      1. I'm attempting a similar formula as step (2) noted in Lana's question but I cannot get it to work.

        The sheet has set due dates for a task to be done. There is a column for the completed date (C) and the days overdue (D) based on the due date.
        I'm trying to get the number of days overdue to show in column D (due date is in C2) if there is not a completed date in C, otherwise if there is a date in C, I'd like the cell to stay blank.

        Tried this formula, but it shows as FALSE when there is a date in C instead of coming up blank:
        =IF(AND(C5=""), TODAY()-$C$2)

        [Row 5 is the first row of data excluding the due date in row 2, so I'm intending on dragging down the remaining rows]

        Hopefully you can help me with this!

        1. Hi!
          I’m not sure I got you right since the description you provided is not entirely clear. However, it seems to me that the formula below will work for you:

          =IF(C5="", TODAY()-$C$2,"")

  23. i need a formula to display a number (2) if the cell says "yes" and display a (4) if the cell says "no"....
    can anyone help?

    1. Here you go:

      =IF(A1="yes", 2, IF(A1="no", 4, ""))

  24. i cannot figure the formula out help!!!
    In cell F20, enter an IF function that tests whether the order quantity in cell E20 is greater than zero. If it is, return the the charge for this item, which is the value of cell E20 mulitplied by cell D20. Otherwise, return a space by entering " " (that is, double quote, space, double quote). Autofill this formula into the range F21:F25.

    1. Hi Ana,

      Here's the formula for F20:
      =IF($E20>0, $E20*$D20, " ")

      Simply copy it down to other cells in column F:
      - select cell F20;
      - move the mouse cursor at the lower right-hand corner of the cell and you will see it changing to a plus sign (fill handle);
      - click the plus and drag it down to fill other cells with your formula.

  25. I have a tricky question...I want sheet 2 to return an if statement that calculates on sheet 1.: =if(MaterialBreakdown[SARA Title 313}="*YES", MaterialBreakdown[Material Name], NA. That is the formula I tried to use, but it gave me an error. I want all materials in column A to list in another sheet if they have yes in column C. I am really bad at explaining this!

    all help appreciated!

  26. I NEED YOUR HELP IN THIS FORMULA:

    =IF(K26="CHEMICAL TANKER",IF(AND(K26>=0,K26=5000,K26=10000,K2620000,550))))),IF(K26="GENERAL CARGO",IF(AND(K26>=0,K26=5000,K2610000,490))))

    THE ANSWER IS= #VALUE

    IS THERE ANY POSSIBILITY TO COMBINE MORE THAN ONE IF STATEMENT IN ONE CELL?
    I WANT TO ADD OTHER IF CONDITIONS IE,"BULK","CARGO" AND SO ON.

    IS THERE ANY LIMITATION FOR THIS CONDITION? TQ

  27. What if I want to say if cells F1, G1, and H1 are blank, I1 should be blank. If F1, G1 and H1 have numbers, then I1 should be F1+G1+H1.

    1. Hi James,

      Should I1 be blank if any of cells F1, G1, and H1 is blank or if all 3 cells are blank?
      And what if any of those cells contains a text value?

  28. Hi,
    I have two membership type groups; member and non-member (column A). I have registration start dates (column B) and registration end dates (column C). I need to confirm that the start and end dates for registration fall within the acceptable date range for both members and non-members. Members range (6/1/15 – 8/31/15); Non-Members (6/8/15 – 8/31/15).

    Thanks!

  29. Hi Guys, how are you?

    I imported data from TXT file when the field BDATE came like below:

    09/09/2013
    09/09/2013
    09/09/2013
    09/09/2013
    30/12/2011
    14/03/2013
    24/09/2013
    24/09/2013
    30/12/2011

    This format is British style (DD/MM/YYYY), when I convert to American style (MM-DD-YYYY) the date that begin > 12 were not converted.
    Somebody knows what to do?

    Thanks!

  30. Hi

    Need to insert if formula where there are four dates (one in each column) and need a yes answer if any of the dates are greater than one date but less than another date. eg. if any of the four dates were greater than 01/06/15 but less than 30/06/15 I need the answer to be yes

    Thanks. LP

    1. Lindsay,

      Please use this formula:
      =IF(OR(AND(A1DATEVALUE("01/06/15")), AND(A2DATEVALUE("01/06/15")), AND(A3DATEVALUE("01/06/15")), AND(A4DATEVALUE("01/06/15"))), "Yes","")

      Where A1, A2, A3, A4 are cells with the dates.

  31. Hi Svetlana,

    What is the formula to highlight non-date cell on particular future dates?

    e.g.

    A1 cell contains Name and I want to highlight this name between 20 May 2015 to 22 May 2015.

    Can you please, help me with the formula for this?

    Regards,
    Sid.

  32. How to set if condition for following:

    =ROUND(VLOOKUP(G6,'2012 IAM Table raw'!A$2:D$122,4,FALSE)*((1-VLOOKUP(G6,'2012 IAM Table raw'!A$2:E$122,5,FALSE))^F6),3)/1000

    this round value will return some value, if values is not return need to set the field value to 0 (zero)

    1. Hi Harish,

      You can try to wrap your VLOOKUP function with IFERROR like this:

      =ROUND(iferror(VLOOKUP(G6,'2012 IAM Table raw'!A$2:D$122,4,FALSE) * ((1-VLOOKUP(G6,'2012 IAM Table raw'!A$2:E$122,5,FALSE))^F6), 0), 3)/1000

  33. Dear Svetlana,
    I tried =TEXT(O2,"dd-mmmm-yy") and which (O2)=IF(B2="delivered", TODAY(), "")
    it workeed yesterday and (cell P2) shown 12-May-15 but it updated to 13-May-15 today morning.
    So how to lock the date(cell P2) at 12-May-15?

    thank you.

    1. Hi Zhao,

      Regrettably, it's not possible to lock the date using formulas. You either have to replace the formula with its value each time manually (Copy > Paste Special > Value) or write a VBA script that automates this.

  34. For some reason, every time I submit my question, it cuts down on how I originally wrote my formula.

    =IF(AND(A1>=1,A1=5,A1<10),5,10))

    This will only return the number 10.

    1. Hi Eric,

      Our blog engine often mangles formulas in comments, sorry for this. Could you please describe your conditions in words, so that I can understand the logic? So, the formula should return:

      5 if ?
      10 if?
      1 if?

  35. Hi, I am trying to write a formula that pulls in a number of 1, 5 or 10. The numbers in cell A1 range anywhere from 1 - 25. I presently have it set up as follows:

    =IF(AND(A1>=1,A1=5,A1<10),5,10))

    The formula takes, but it only returns the number 10 in all instances. Help!!

  36. Hi, I am trying to write a formula that pulls in a number of 1, 5 or 10. The numbers in cell A1 range anywhere from 1 - 25. I presently have it set up as follows:

    =IF(AND(A1>=1,A1=5,A1<10),5,10))

    The formula takes, but it always returns the number 10 in every instance. Can't figure this out. Hoping you can help.

  37. Hi, working on an excel spreadsheet for invoices.
    Column A is quantity, b & c are description, D is unit price and E total

    I need a formula that calculates A*D in column E but remains blank when column A is blank

    Thank you

    1. Hi Fitz,

      Try the following formula:

      =IF(A2<>"", A2*D2, "")

      1. if the same way I want to get "Yes" if value greater than A1, else remain blank. Also if there is no value in A1 still remains blank

      2. awesome. perfect. thank you Svetlana

  38. =IF(B2="delivered", TODAY(), "")

    I use this formula to generate delivery date, but i found that the date will updated to the date of next day... So how to maintain the date there for me to check the delivery date few days later? thanks.

    1. hi..
      i have just got answer from your previous post that

      "How to convert date to text using Excel TEXT function and no-formula ways"

      ...ha, it`s helpful, thank you very much, but i am not sure whether it will be updated tomorrow

  39. =IF(CV2<=28,"Poor", IF(28<CV2<=42,"Borderline","Acceptable"))
    I wrote the formula above but it's only selecting "Poor" and "Acceptable", leaving out "Borderline" Any help?

    1. Hi Phil,

      Regrettably IF cannot understand expressions like 28<CV2<=42. You have to use an AND statement is this case:
      =IF(CV2<=28,"Poor", IF(AND(CV2>28, CV2<=42),"Borderline","Acceptable"))

      But in fact, checking for CV2>28 is superfluous and you can put it simply as:

      =IF(CV2<=28,"Poor", IF(CV2<=42,"Borderline","Acceptable"))

  40. Friends I want to a formula who auto calculate with given material with its value.

    Ex.

    If Material is Sand and its value 41....its divided by its net weight(12000)

    I want to just type different Materials Name like sand and its auto divided with weight.

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

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

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

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

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

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

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

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

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

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

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