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 16. Total comments: 4823

  1. i cannot do the addition and subtraction in one cell in Total.
    like - if c3>1 add and if c3<1 than it is 0

  2. I'm trying to use a logic function to get standard pricing calculation from one worksheet to another. I thought this would be done through =if(A2:A22 = !sheet1$A$2:$A$22, c2:C22). What am I thinking incorrectly on the logic side?

  3. Hi,

    Im trying to set up the following:
    =IF(FOTB!A3="PID: Sync Identity to network"; "=FOTB!C3"; "0")

    So I'm trying to accomplish that:
    When A3 on sheet FOTB equals the text PID: Sync Identity to network
    the value from cell C3 should get copied to the cell i'm pasting this formula in.

    The issue here is that excel just shows =FOTB!C3 instead of the value of the cell.

    How can I fix this?

    kind regards,

    Glenn

    1. Hello!
      Use something like this

      =IF(A3="PID: Sync Identity to network"; C3; 0)

      This should solve your task.

  4. I am trying to write a formula that if A1=number AND F1>=different number, then A1 turns red. I'm trying to track mileage of my fleet and when they are due for oil changes. A1 is the unit # and F1 is the current mileage. If F1 is greater than or equal to the oil change needed mileage, then A1 would turn red.

    Thanks.

  5. how do we add an extra number to an formula that already has a existing formula. And how do we add a common number to a series of cell having different formula

  6. Hi! I need your help. What I want to happen is every letter that i enter should the next cell must present a number. for example
    W=1
    H= 2
    I= 3
    T= 4
    E= 5

    But not just one letter.. If I want to type "WH" the next cell should present "12" since W=1 and H=2 or if I want to type "WHI" next cell should display "123". and if it is shuffled like "HIW" it should display as "231".

    Thank you very much

  7. Thank you for the info. Is it possible to put in the If function a range of cells ?
    On a column (A) I have a list of emails that I need to classify. In Column B I was hoping to have the valid emails displayed and on column C the invalid emails. I have the list of valid emails on another sheet (Valid emails).
    The way I wanted it to work is: if an email in column A is on the 'valid email sheet', then it should display said email on column B, if not, display "no". I started with the following formula but it only works for the one email.
    (in cell B2) => IF(B2='Valid email'!$A$2:$A$70;B2;"no") (range of emails in valid sheet is from A2 to A70)
    My problem is when I copy it down to the rest of the column it does not work and all values are "no".
    What should I add to the formula so it looks for the value in the other sheet and displays said email or displays no?
    Thank you very much!

    1. Hello!
      Please try the following formula:

      =IF(ISNUMBER(MATCH(B2,$A$2:$A$70,0)),B2,"No")

      I hope this will help, otherwise please do not hesitate to contact me anytime.

  8. Hi, I'm trying to combine two functions, I have a requirement to contact customers every 6 months before they begin receiving our services and once a year after. I'm trying to get the function to identify the last date contacted, then based on if there is a Yes or No in column B2 return a Next Contact date either 6 months or 12 months in the future. This is the formula I'm working with but I can't seem to make it work... Any thoughts?
    =IF(B2='Yes',[EDATE(A2,S2)],[EDATE(A2,S3)])

    (S2 refers to the 6 months and S3 refers to the 12 they are just single cells with a 6 or 12.)

    Thanks!

    1. Hello!
      I have not been able to verify your formula. It doesn't work for me. This formula will return TRUE if the date in column A is the most recent.

      =A1=MAX($A$1:$A$100)

      You can copy this formula down along the column.
      For me to be able to help you better, please specify which formula you mean and describe the problem in more detail.

      1. I'm not looking for it to return anything. I'm looking for it to find a different solution based on what the column says, for example if the Date in A is 1/1/2020, if column B says YES I want it to Return A2+6months = 7/1/2020 in Column C and if column B says NO I want it to return 1/1/2020+12 months = 1/1/2021 in column C Then I'm going to set up conditional formatting to highlight the column based on the time out from the Column C information but that part of the spreadsheet is working well.

  9. ( A )
    (ROW 1) TIME IN 24:00
    (ROW 2) TIME OUT 8:00
    (ROW 3) HOURS WORKED 8:00
    I have row 1 and 2 formatted as [h]:mm and the following formula in Row 3:
    =IF(A2>A1,A2-A1,1-A1+A2)
    What I need is for the formula to return blank or 0 if no times are listed in Row 1 or 2, right now it returns 24 if cells are empty.

    Any assistance would be greatly appreciated, thank you

    1. Hello!
      If I got you right, the formula below will help you with your task:

      =IF(OR(ISBLANK(A1),ISBLANK(A2)),"",IF(A2>A1,A2-A1,1-A1+A2))

      You can learn more about ISBLANK function in Excel in this article on our blog.

      1. It worked, thank you so much, I was missing the "ISBLANK" for A2, much appreciated.

  10. Hi, I am impressed that someone is actively replying to comments. plz help, all I wanna know is a function for this sort of rule. If A:A has a text of "name", B:B should be on E1, then E1 will add all value from B that has "name" on it. idk if thats clear but im no expert. help

    1. Hello!
      Sorry, I do not fully understand the task.
      I recommend paying attention to the SUMIF function.
      If this is not what you wanted, please describe the problem in more detail.

  11. hello alexander i need you help

    formula for fresh eggs order

    given:

    guest count = 3515 heads
    days = 1
    daily consumption of eggs per guest = 1.46 pcs
    eggs left before ordering = 300 pcs

    How many eggs i have to order given below using a formula in excel?
    Consider also that i still have 300 eggs left, see above

    guest = 751 heads
    days = 15
    daily consumption of eggs per guest = 1.46 pcs

    Thanks

  12. hi good people i am hoping to get a help from you all .... i want to pull out all the data with the same name in a new cell how can i used or what conditional if function to use please help thank you

  13. What's the syntax for the following?

    If A1=Yes, then display value from Column L , Column B.

  14. This is very useful website. This article is really helpful. Thank you so much for sharing this great knowledge

  15. I want to select out a subset from a list(rows) of purchases- columns have date price, article, buyer etc.
    I can make a column with "yes" or "No" which defines the rows I want, but now how do I select the whole row and copy onto new chart, or hide the rest?

    1. Hello!
      To get a list of rows conditionally, I recommend using the FILTER function. You can get detailed instructions in this guide.
      I hope I answered your question. If something is still unclear, please feel free to ask.

  16. Hi,
    Could you guys please help me to clear this below issues.

    Cell A1 "APPROVED"
    Cell A2 "APPROVED"
    Cell A3 "APPROVED"

    If(Cell A1:A3="APPROVED", Cell A4="APPROVED", "NOT APPROVED").

    How i can solve this issue.

    1. Hi,
      I believe the following formula will help you solve your task:

      =IF(SUM(--(B1:B3="APPROVED"))=3,"APPROVED","NOT APPROVED")

  17. Hi I really hope I can explain myself well. So basically, if a column contains a 'No' entry, then most of the columns that come after will have an 'N/A' entry. I'm trying to automate this but what I'm struggling to do is if the condition is false, then I don't want anything to happen to the cell (whatever entry in the cell should remain). For instance, If it's a 'No' then I want 'N/A' but if it's a 'Yes' then I'll have to put a date. But what happens is that when I create the formula for the first cell and tries to drag, it changes all my dates to blank which is not what I want. I want the dates to remain.

    Any help would be greatly appreciated, thanks

    1. Hello!
      Sorry, you didn't write your formula. So I am assuming you are using relative cell references. They change when copied. Use absolute cell references.
      If this is not what you wanted, please describe the problem in more detail.

  18. Hi,
    If I select name from dropdown list in cell A1, automatically name of country of the person should display in A2 and his identification number should display in A3.
    Please help me for setting this formula in excel.

  19. I want to use the if function to populate a cell with 1 of 3 possible values. I have a start time and a finish time which gives a total time worked. I want to take the total time worked and if it is less than 5:30 hours worked then 0:00 break, 5:30 hours to 7 hours is 0:30 break and over 7 hours is 1 hour break. Help would be appreciated.

    1. Hello!
      If I got you right, the formula below will help you with your task:

      =IF(TIME(7,0,0)>B1,TIME(1,0,0),IF(TIME(5,30,0)>B1,TIME(0,30,0),0))

  20. Hello,

    I was wondering if anyone could help me - I am stuck with figuring out a formula to calculate a commission sheet with percentage according to a job role.
    example:
    Person A - gets a commission value in cellA1 and B1 added together however Person B only gets 10% of value in Cell A.

    Can anyone help me figure this formula out? - I tried to make it sound a little like:
    If cell J5="Y" then cell J6 = A1+B1 or if cell J5="N" then J6=10%ofCellA1

  21. I need help with the following

    cell E14 has check box
    cell I14 has check box

    cell E4 has data
    cell F4 has data

    cell F14 is the cell I need filed with the correct data

    What I am trying to accomplish
    if cell E14=true and cell I14=true then fill cell F14 with data from cell E4
    if cell E14=true and cell I14=false then fill cell F14 with data from cell F4

    thanks for your time
    Jason

  22. Im trying to have a column in excel that uses 2 equations based off of a word that is placed in another column .

    for example if J5 says Suburban i want the equation in N5 to be M5*9/100 and show the answer to the equation but if J5 doesn't say this and says Mercedes i want the equation to be M5*11/100 and show the answer.

    Also how do you copy to function down the column so it is using the right line number.

    I thought that I had it but its not giving me the totals

    Thank you!

  23. Thank you so much it is working now

  24. In the above formula "OP" condtion is working fine...But in the "IP" when i enter in the cell 4 ,then it is showing "OUTSIDE".

    As per my condition for "IP" G25 then "OUTSIDE"

    Please support to solve this

  25. Thank you so much...i will check

    If Cell G2 contain text ,then how we can solve

      1. This is working fine

  26. And with this i also need to add one more condition....if G2 cell not cotain number then will show "blank"

      1. In this formula "OP" condtion is working fine...But in "IP" when i enter 4 ,it is showing "OUTSIDE".

        As per my codtion it should only when i enter 5

        1. Please help how to solve thiscalculation...In "IP" G25 then "OUTSIDE".

  27. Kindly help to combine below formula together...Actually i need to put below formula in one cell

    =IF(AND(K2="OP",G2<4),"WITHIN TIME","OUTSIDE")
    =IF(AND(K2="IP",G2<5),"WITHIN TIME","OUTSIDE")

  28. Hello,

    I have to IF/Then statement of

    =IF(DH53=DI53,"matches", "doesn't match")

    Cell DH53 = 0.00 and DI= 0.00

    For some reason it's returning a Doesn't Match result but it does match. I have multiple that return back the Matches results but a few that return back the doesn't match result even though the two cells do match. Am I doing something wrong? I've tried reformatting all the cells so they are all the same format but nothing seems to change. Why would the IF/Then statement return back a false result if it is in fact true

    Thanks so much for your help!

    1. Hello!
      Unfortunately, without seeing your data it is difficult to give you any advice. 1. Perhaps one of the values is written as text. 2. If these values are calculated by formulas, then they may differ in decimal places. For example, 0.0002 and 0.000008. In the cell, you will see 0.00. I recommend using the ROUND function in this case.

  29. I have a problem please help I'm very new to this, sorry.
    I want to show the result only if the full operation is done for example.
    K15 =C15*E15+F15 otherwise 0

  30. Hi!

    I'm looking for some help in using an IF statement to perform a math operation, I can’t seem to get it right:

    I have:
    Column A: Firm (either A, B, C, D or E)
    Column B: Measure (either sales, price, or promotional price)
    Column C: Product (a lot, but coded as numbers)
    Column D-FB: Value of measure per week (155 weeks in total)

    I want a cell to return: ((sales 1 * price 1) + (sales 2 * price 2)) / (sales 1 + sales 2)

    Where:
    Sales 1: sales of firm A for product 1
    Price 1: price of product 1 of firm A
    Sales 2: sales of firm A for product 2
    Price 2: price of product 2 of firm A

    Thus, firm is always A, but measure and product differ. Then, I would autofill the cell to the right (from column D to FB to create a new row). I would like to do the same for promotional price.

    I hope I explained it well enough and any help would be much appreciated! Thank you!

      1. Thank you for your quick reply!

        For example:

        A1: Firm (header)
        A2: A
        A3: A
        A4: A
        A5: A

        B1: Measure (header)
        B2: Sales
        B3: Sales
        B4: Price
        B5: Price

        C1: Product (header)
        C2: 1
        C3: 1
        C4: 2
        C5: 2

        D1: Week 1 (header)
        D2: 1,670
        D3: 9,813
        D4: 1.42
        D5: 1.83

        E1: Week 2 (header)
        F1: Week 3 (header)
        etc.

        =IF((D2+D3);((D2*D4)+(D3*D5))/(D2+D3);0) results in 1.77

        This 1.77 is then the new combined price of product 1 and 2 for firm A for week 1.

        In this example, I’ve already filtered on the right firm, measure, and product, but I would like to make a function where I would only have to type in the firm and product and not manually select them as I’m doing now. So for D2 * D4 for example, only multiply cells if one cell is sales of product 1 for firm A and the other is price of product 1 for firm A.

        I hope this makes sense, thank you in advance!

        1. Hello!
          I’m not sure I got you right. If your criteria are firm, measure, and product, then you can find the desired cell in column D using the INDEX + MATCH function, as described in the article "Excel INDEX MATCH with multiple criteria".
          The criteria for cell D2 are "A", "Sales", 1. For D4, "A", "Price", 1. And so on.
          I hope it’ll be helpful.

          1. Yes, I've managed to create the formula with the use of index and match! Thank you very much for your help!

  31. Hi there! I'm looking for assistance with an IF Function.

    I'm looking to create a formula that produces a value IF the value falls between a set of dates.

    For example -

    Date - 05/01/2021
    Value - 600

    Start Date 1 - 01/01/2021
    End Date 1 - 30/01/2021

    Start Date 2 - 01/02/2021
    End Date 2 - 28/02/2021

    The formula should return only 600 as it falls in between Start and End Date 1. Ideally I'd want it to be able to calculate the total value from a List i.e.

    I.e. list of Dates from A5:A55, return value if between Start and End Date 1, Return 0 Value if not between Start and End Date 1

    Hope that makes sense?

  32. I need a formulas for if the cell has a Y then this other cell will enter $25.00 if not it is $0. Please help me. Thank you .

      1. Thank you. It worked!

  33. =If(A2=0,"Closed",(IF(istext(AA2),"Closed","Active"),(IF(AA2=Cancel,"Canceled",AA2=OnHold, "OnHold")))

    My formula will not work. It works when I only put
    =If(A2=0,"Closed",(IF(istext(AA2),"Closed","Active")
    Or
    =IF(AA2=Cancel,"Canceled",AA2=OnHold, "OnHold")
    But I need them together to show the status of the reports if they were to fo on hold or be canceled.

    Any help would be appreciated

  34. Hi there, im trying to put together IF function formula and im struggling.

    It goes something like this,

    =IF(D41="Something1", "$1.000",
    IF(D41="something2", "$1.400",
    IF(D41="something3", "$1.000",
    IF(D41="something4", "$1.000",
    IF(D41="something5", "$1.800",
    IF(D41="something6", "$1.000",
    IF(D41="something7", "$1.400",
    IF(D41="something8", "$1.300",
    IF(D41="something9", "$1.000",)))))))))

    IS this even possible ? how many IFs is possible this way?
    This would really help me .
    thanks in andvance

  35. Really good blog,thank so much for your time in writing the posts.

  36. Really good blog,thank you very much for your time in writing the posts.

  37. Very good blog,thank so much for your time in writing the posts.

  38. cool site. Thanks for showing us.

  39. I have got a range of TEXT acronyms in a separate sheet. I am using the following formula to assign a value to rows when they have a corresponding value in a column of the separate sheet.

    =IF(COUNTIFS('sheet1'!B:B;"*"&B2&"*")>0;"category1";IF(COUNTIFS('sheet1'!A:A;"*"&B2&"*")>0;"category2";IF(COUNTIFS('sheet1'!C:C;"*"&B2&"*")>0;"category3";"category4")))

    The formula works most of the times except when a cell contains but a value of one of the category even if not pertaining to it.

    To better explain myself: I have got a value which is "AU" which pertains to category4, but the results for it is category1 because, the latter contains a a value that is "JAU".

    How can I made the formula to include all the text, thus making AU displayed as a category4?
    Thank you in advance.

    1. Hello!
      It is not clear from your explanation whether cell B2 and column Sheet1!B:B must match exactly, or B2 must be contained within any value in the column.
      Perhaps instead of “*”&B2&”*” in the formula, you need to write B2. Then the error you described will not be.

      1. Thank you!

        Cell B2 has a text value to be checked if present in Sheet1!B:B. Hence, B2 must be contained within any value in the column.

        If I use B2 instead of “*”&B2&”*” the result for every column is category4. Is that because the value in B2 is a TEXT?

        1. Hi,
          Again, you didn't say - do you want an exact match of values or a partial match? Your first formula calculated overlapping values. Give an example of the raw values you are comparing. Check for extra spaces in your values.
          Without seeing your data it is difficult to give you any advice. Please provide me with an example of the source data and the expected result.

          1. Thank you Alexander,
            I want the exact match of values.

            I have got a column containing codes such as:
            Codes:
            AF
            BR
            BW
            AU
            JAU

            In another sheet I have got 3 different columns which orders the above mentioned codes by categories:

            Category 1 Category 2 Category 3
            AF BR JAU
            BW

            Hovewer, there are some codes which are not included in the categories.
            Such as AU.

            The formula I created checks if some cells in the categories list contains the values of the codes column.

            However this does consider also consider partial values inside the cells i.e. "AU" is categorized as Category 3 - as in category 3 there is a value "JAU".
            How do I rewrite the formula to make it take into account the whole value of the cell and this making AU (which does not belong to any of the three category list) be categorized as a 4 category (which is "not pertaining to any category")

            Thank you in advance

            1. Hello!
              If you need an exact match between values, then you need to use the formula that I already recommended to you.
              If the AF code does not match the AF category, then these values have extra spaces or non-printable characters. Compare these cells using the "=" operator to check.

  40. Really good site,thank so much for your effort in writing the posts.

  41. Good morning, I am trying to make it where if I type N in colum J:J then columns K:K, L:L, M:M, N:N also populate N as well, can anyone help with this formula.

    1. Hello!
      Please try the following formula:

      IF(J1="N","N","")

      Write this formula down in columns K,L,M,N.
      I hope this will help

  42. What is a equation blank -9 equals one

  43. Hello, is it possible to have a formula return a date? I want Excel to return a date if a column says completed. Thanks!

  44. Hii.
    I want to display a list of names of students who scored a 0 in a test.
    The problem I'm experiencing is of duplicacy.
    Please help.

  45. Hi Guys,
    Can you help me to solve this below mentioned if function in excel?

    =if(E1:E5="APPROVED", "APPROVED", "NOT APPROVED")

    1. Hi,
      Anyone can help me to solve this below mentioned if function in excel?

      =if(E1:E5="APPROVED", "APPROVED", "NOT APPROVED")

      In my document sheet,
      Column E,
      Cell 1 to Cell 5 will be either " APPROVED" or "REJECTED" or "NOT APPROVED"
      In cell 6 I need to use the above function. Text of E1 to E5 are 'APPROVED" then the cell 6 will be shown as "APPROVED" or "NOT APPROVED".

      1. Hello!
        Please use the following formula/the formula below to solve your task:

        =IF(SUM(--(E1:E5="APPROVED"))=5,"APPROVED","NOT APPROVED")

        I hope this will help

        1. Hi Alexander,
          I have tried but it's not working. Could you please explain to me the formula?

          =IF(SUM(--(E1:E5="APPROVED"))=5,"APPROVED","NOT APPROVED")
          about this "--" also =5

          1. Hi,
            If all cells E1 through E5 contain APPROVED, the formula returns APPROVED. What exactly isn't working?

  46. Hello

    I'm trying to create an if formula so that if I type into a cell any number in the adjacent cell it will return there name

    EG
    Number Students Name
    1 Joe Bloggs

  47. =IF(Sheet2!B3:B15="E1","8","-")
    This is Selvakumaran, for the above given formula i have using this to create a titme table for my teachers, but I couldn't get what i have expect, can u please help me?
    I have entered E1 in one of a cell in a range and I need result as "E1" in another cell but I couldn't get it.

    1. Hi,
      The IF function does not work with data ranges. Therefore, the expression

      IF(Sheet2!B3:B15= ......

      is incorrect.
      I cannot give more detailed advice, since you did not explain the problem in detail.

  48. I am having trouble with a formula hope you can help, I am trying to create a formula to put text in a cell.
    I have a cell that reference with a set target which is a percentage 85% and then and
    I want it to say if Col L7 which is a percentage value say 75%, is greater then a desire target which is in col K7 (85%) put YES if it is 85% or over put put no in NO if it is not

    IF L7 is >=(K7)85% "YES" but if is under <Less than 85% say (K7) "NO"

  49. Hi
    I made this below chart and I want a indicator in AVAILABLE Cell where I need red mark will show if Qty will be 5 Pcs or less than 5 Pcs. Please help me to get this problem solved. Here in AVAILABLE Cell I put the formula like this =IF([@AVAILABLE]="0","-1",[@STOCK]-[@[SALES QTY]])

    STOCK SALES QTY AVAILABLE
    20 Pcs 11 Pcs 09 Pcs ▲
    10 Pcs 09 Pcs 01 Pcs ▲
    05 Pcs 05 Pcs - ▼
    15 Pcs 04 Pcs 11 Pcs ▲
    09 Pcs 04 Pcs 05 Pcs ▲
    10 Pcs 05 Pcs 05 Pcs ▲

    I tried many ways changing the number inside the fomula but failed to correct this.
    Thanks
    Sazedul Munna

  50. Hello, I'm hoping you can help.
    I'm trying to create a formula for the following
    Have multiple Dept (example 3226.7191 33.24.71, etc in Column L) and I have cost associated to each line items in Column R.
    I want to create a formula which summaries the charges for each Dept.
    For example - the forumla would look down column L and if Dept=3226.7191 it would then look at column R and cross-reference all of the charges that appear in column R with all the time that Dept 3226.7191 appears and provides a summary of those charges

    1. Hello!
      You can get a list of values by condition using the FILTER function. Read this detailed guide.
      I hope this will help, otherwise please do not hesitate to contact me anytime.

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