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 5. Total comments: 4813

  1. Hi
    How to write this formula:
    If cell B4 is >1 or =15 then B5=1
    If cell B4 is <15 but < 30 then B5=2
    If cell B4 is 305 but < 45 then B5=3

    Ihave been trying to use IF(AND/ OR but I am not getting it write.

  2. Mohonbantuan untukrumusnya
    jika A1 saya isi P maka A2 isinya 100.000, jika A1 disi T maka A2 isinya 200.000, jika A1 di isi K maka A2 300.000

    mohon bantuannya, trus cara aturnya gimana.
    terimasaik,

    1. I want the numbers to showi the first column automatically, as i enter the names or items in the next column. How can i do that? I remember something like: =if(b2=???, row-1, ""), but cannot remember the exact formula.
      Thanks in advance

      1. Hi! I don't know what numbers you want to display. You can get the row number by using the ROW function. Check for an empty cell using the ISBLANK function or the <>"" expression. For example:

        =IF(NOT(ISBLANK(B2)),ROW(B2),"")
        =IF(B2<>"",ROW(B2),"")

  3. Hi!
    I have tax rate ranging from 5% - 20% and each are give the rate

    5,000 is nil tax
    5,001 - 10,000 is 5%
    10,001-15,000 is 10%
    15,001 - 20,000 is 15%
    20,001- above is 20%

    How can this be incorporate in the formula?

  4. I have 2 columns. One of the column is labeled "Earnings Overpriced". In that column I have successfully calculated either "Overpriced" or nothing appears in the cells. In the second column labeled "Cash Flow Overpriced". In that column I have successfully calculated either "Overpriced" or nothing appears in the cells. In a third column I want excel to look at both these column cells and when "Overpriced" appears in both columns I want excel to calculated in the third column "Earnings and Cash Flow Overpriced". When the "Overpriced" appears in only the Earnings column and the Cash Flow column has nothing in the cell, I want excel to calculate "Earnings Overpriced". When the "Overprice" appears only in the Cash Flow column but the Earnings column has nothing in it, I want excel to calculate "Cash Flow Overpriced". When both columns have nothing in them, I would like excel to place a "Buy" in the cell. This seems simple to me but I can't get my formula to work.

    Appreciate any help you can provide. Tony

  5. Hello,

    - Column A contains % change values that are positive and negative. Column A has rows that contain no values.

    -I'd like to display the % change values that are positive in Column B and nothing if a Column A row contains no value.
    -I'd like to display the % change values that are negative in Column C and nothing if a Column A row contains no value.

    Thank you very much!

    1. Hi! Please re-check the article above since it covers your task. If I understand correctly, thy this formula

      IF(A1>0,A1,"")

  6. Hi there!
    Loved using this for my basic data entry but now i have a super complicated entry! (in my mind at least)

    I have multiple entries containing different "finishes" eg Black 16mm in A B C D E
    I need a cell to basically run a bunch of formulas and add text where the values are matching
    for example i have a black 16mm board but i have 5 different finishes for this board - we'll call them A, B, C, D, E
    Can I get a single cell formula to basically look at all these values (A-E) and spit out the value i need like "Black 16mm C"

    I currently have a formula saying if "A" then TEXT, if not ATTENTION but having to do this for many seperate values is time consuming!

  7. I compare values in two columns of a row and using ÍF" condition I confirms whether they are same.
    But , even ifthe values are same, the Ïf"condition formula returns "False" in certain cases( not in all cases).Why it is so?

  8. I need to write a formula that states if a values multiplied by another value plus a value divided by 2 is less than a value in a cell it will equal that number in the cell plus 1

    1. I hope you have studied the recommendations in the tutorial above. It contains answers to your question.

  9. Hi,
    I have a value in cell b1("Date") and b2("Transferred"). If B2=Transferred, then b1 and b2 must return a blank values
    If b1 and b2 have no values, then cells remains blank
    if b1("date") and B2 says Dismissed or Resigned, then both cells stay as is.
    Please assist.
    Thank you

    1. I don't understand how B2 can simultaneously have the value "Transferred" and return an blank value. Explain.

  10. A2, B2 & C2 having NA then result come delete or A2, B2 & C2 HAVING OTHER VALUE THEN result come no action

  11. Help. Can you help me with a formula for this scenario:

    If a number is between 40,000-83,999 the multiply that number by 15% or 8,399, whichever is less, if a number is between 84,000-124000 then multiply that number by 10% or 9,999, which is less...

    Thank you so much if you can help me with this.

  12. This is a fantastic resource. I am diving into making better spreadsheets at work, and already enjoying conditional logic built into Excel even though we are using MS Excel 2010.

    I have a spreadsheet that I have made for job numbers. I have a "due date" in Column Cell D3 which is using icon sets to place a red circle icon and second condition for the same cell to have format of the cell shaded red. This works well for a visual of when the date has reached and is now expired, the visual is perfect.

    However, I have another column with "Completed date" which is a manual entry in column Cell K3. I would like that when we add a date in K3, this is a trigger to change the icon set to use a green tick icon, and then change the shading of the background to green.

    I cannot work out the conditional logic for this scenario.

    Many thanks

    1. Hi! Create a conditional formatting formula, where you use the logical AND function to combine the conditions for cells D3 and K3.
      The formula might look like this:

      =AND([conditions for Cell D3],(ISNONTEXT(K3),K3>0)

  13. I have an excel sheet I am working on and can't figure out the formula to use.
    So I have column G "Procedure Type" (Example: XXX, YYY, ZZZ) and column L Start date. If Coumn G is XXX, I need it to calculate how many cells in column L has a date (not counting the blank cells).

  14. Hi!
    Thanks for your article. I have some work to do more. Is there any way to put “else condition” into another column?

    Thank You.

  15. hi, I tried to write a formula about if a certain column appear a certain key word "gas", then the column of CoC equal the column contractor, or appear "na"
    =IF([@[Facility
    Owner]]="gas",[@COC]=[@[Contractor
    /Excavator]],"na")

    it appear" na" correctly if the value is not "gas", but when the context is gas, the value appear 0, I don't know how to fix this problem. can you help?

    1. Hi! I can't check your formula because I don't have your data. When the context is "gas" then the expression [@COC]=[@[Contractor/Excavator]] is fulfilled and returned FALSE or zero.

  16. Seeking help on how to assign formula if you have a range of variables

    For example

    If the cell contains 0, then the result should be 0
    If the cell contains Nos 1 - 5, then the result should be A
    If the cell contains Nos 6 - 10, then the result should be B
    If the cell contains Nos 11 - 15, then the result should be C
    ....

  17. I work in a Coffee plantations where our estates are coded in the following format:
    "EAPCPK51" - The first three letters denote the estate name, "EAP", the second three letters denote the division name, "CPK" and finally the number denotes the block number. How do I decode these codes into three columns namely, estate, division and block number. Is there a formula for this?

  18. I'm building an attendance tracker where several conditions must be met.
    Cell B4 - Duration >4.00 or <4.00
    Cell C4 - Reason = Illness/Injury, Family Emergency, Other
    Cell D4 - Excused/Unexcused = Unexcused
    Cell E4 - IF B4 is greater than 4.00 and all other conditions are met, result is be 1.00; IF B4 is less than 4.00 and all other conditions are met, result is 0.50; IF D4=Excused (regardless of other conditions), result is 0.00

      1. Correction...here is the formula I used... Still getting tripped up somewhere.
        =IF(AND(B4>=4.00), (c4="Illness/Injury","Family Emergency","Other"), (D4="Unexcused"), "1.00", IF(AND(B4<4.00), (c4="Illness/Injury","Family Emergency","Other"), (D4="Unexcused"), "0.50")))

        1. Hi!If one of several conditions is true, I recommend using IF OR statement. For example

          =IF(AND(B4>=4,OR(C4="Illness/Injury",C4="Family Emergency",C4="Other"),D4="Unexcused"), "1.00", IF(AND(B4<4,OR(C4="Illness/Injury",C4="Family Emergency",C4="Other"),D4="Unexcused"),"0.50"))

      2. A little more direction is needed. Are you able to show me the formula?

        1. =IF(AND(B4>=4.00, c4="Illness/Injury""Family Emergency","Other") D4="Unexcused"), "1.00", IF(AND(B4<4.00, c4="Illness/Injury""Family Emergency""Other"), D4="Unexcused"), "0.50")

  19. Basically, what I need is:

    If H2 is "A" then enter 234 in K2, OR if H2 is "AB" then enter 456 in K2, etc...etc...

    Note. This sequence has four letter to number combinations.

    Thank you

      1. Thank you

  20. Hello, I have columns that has "Yes, No, Yes" as an answer. If I have all 3 as "Yes, No, Yes", my formula should reflect "Yes". And if one of the 3 has a different answer, (i.e "No, No, Yes"), my formula should reflect as a "No". How can I do this?

    i.e Column H = Yes, Column J= No, and Column K=Yes and result in Column N should be Yes.
    if Column H answer is No then Column N Should reflect as NO

    1. Hi!
      If I understand your task correctly, the following formula should work for you:

      =IF((H1="Yes")+(J1="Yes")+(K1="Yes")>1,"Yes","No")

      1. Thank you for your help Alexander. Unfortunately, it did not work.
        (H1=Yes)+(J1=No)+(K1=Yes) should give me a result of "Yes"
        And all other combinations should result as "No"

        I tried and modified the above given formula but it does not work as I want it to be.

        1. Hi! The formula I sent to you was created based on the description you provided in your first request. However, as far as I can see from your second comment, your task is now different from the original one.
          Use IF AND statements:

          =IF(AND((H1="Yes"),(J1="No"),(K1="Yes")),"Yes","No")

          1. Hi! Sorry if I was not clear on my first message. The new formula worked! Thank you

  21. I am trying to write a nested formula. In cells A25:C25, the value is either "Paid" or "Unpaid". I would like to write a formula in a single cell (G30) such that the IF statement evaluates the entire range (A23:C25) ... if the value of a cell = "Paid", do nothing and move to next cell in the range, ... but ... if the value of the cell = "Unpaid", I want the value of another cell to be added together (Cell G30 should return either 0 or a SUM (of all cells in this range =Unpaid)).

    For example, if A25="Paid", do nothing and move to B25. If B25= "Unpaid", go to B23 and capture that value (5), then go to C25. If C25="Unpaid", go to C23 and capture that value (10). Now add B23 + C23 (but not A23). If this can work, the return value on G30 would be "15" (because two of the cells in the range =Unpaid, so their associated values (in Row 23) were added together.

    I tried IF with AND and with OR, but I could not get the "calculate across the range" to work; I keep getting errors or the value of only one cell (like B23). I cannot get the SUM calculation to work properly.

  22. Hello,

    I have a column with different values "RN, OT, PCC, " I am trying to ask if J2 = RN, match H2 cell to these values, if the value matches return 4 or 5, and so on if cell J3 matches RN, Ot, Pcc, and give them all different values to match?

    =IFERROR(J2="RN",IF(AND(H2>=1.48,H2=1.47,H2=1.63,0,0))))*IF(J2="PT",AND(H2=1.19,H2>=1.33,4,IF(H2=1.34,0,0))))

    1. Hi! It is very difficult to understand your formula. However, AND(H2>=1.48,H2=1.47,H2=1.63,0,0) makes no sense because these conditions can never be met at the same time. It is not clear why 0 is needed here. I can assume OR(H2>=1.48,H2=1.47,H2=1.63).
      Maybe this article will be helpful: Excel IF OR statement with formula examples.

  23. I'm trying to do a long list of variable consequences. The line I am trying to do is, in simple terms, IF cell=A, 1,m if cell =B, 2 etc. But I am getting an error that it is not complete.

    1. Never mind, I found my error. Thank you.

  24. I have sheet as: rows has days like: sunday, monday etc for a whole month and column has present or absent. now i want to make formula which will give me count of how many days someone absent on friday and saturday on that month

  25. Create a formula in cell I4 that displays the word Yes if the value in cell H4 is less than the discontinue threshold in cell B21, otherwise the word No is displayed. Your formula must use an appropriate reference to cell B21 so that it will copy correctly. Make sure to use structured references when referencing cells in the table.

  26. I need help with a formula that will look at Column A and compare it to Column B in sheet 1. If there is a number in column B in sheet 1 display the contents of column A in sheet 2, if it is blank display "Need" where the number would go in sheet 2.

  27. Hello,
    I have a formula that will pull registered number of attendees over expected when there is a value. However, there can be duplicated rows of registered attendee numbers. I inserted another formula into the J column to flag this and it inputs the text "duplicate".
    Is there a way to add to the formula below to input 0 into I2 when the "duplicate" text exists"?
    =IF(I2="",G2,I2)
    Thank you,
    Lisa

    1. I mean 0 into H2 which is where this formula exists.
      Sorry.

  28. I am trying to have a column that states if a specific cell has a number greater than or equal to 30 than show "overdue" otherwise blank. I am using this formula [=IF($J5>= 30, "OVERDUE", "")]

    however it also will mark overdue for the J column cells that have the formula [=IF(G4>1, TODAY()-G4, "")] in their cell even if the cell is technically blank. How do I exclude the formula and only look for cells that have a number value greater than or equal to 30

    1. Hi!
      Based on your description, it is hard to completely understand your task. However, I’ll try to guess and recommend using ISFORMULA function to check whether a cell contains a value or a formula.
      If this is not what you wanted, please describe the problem in more detail.

      1. I have column J contains the formula =IF(G4>1, TODAY()-G4, "") and I want to use the formula =IF($J5>= 30, "OVERDUE", "") in column K so that it showcases whether a specific entry has been over 30 days. The formula for K works except that it also puts a value in column K for rows that column J is technically empty but still contains the formula text string. I am looking to find a way where the column k formula will only place "overdue" when connected to a number value >=30 and exclude those cells with the formula text string. Hope that makes sense.

  29. I have a list of names in one column with a column of one of 9 possible values associated with it. e.g A1 = Alan, B1 = Apple, and Apple & Alan are associated.

    I want to visually show by variable the names associated with that variable, ideally in a 9 box chart. E.g under the variable Apple would be all the names associated with Apple. Under Banana would be all the names associated with Banana, is there a way with a nested IF statement to print those names automatically? The list will change periodically so want to avoid manual intervention is possible.

    Thanks!

  30. I'm trying to do a combination of an If then statement and a textjoin function.

    Common language of what I'm trying to say if A26:A167="SB", then TEXTJOIN C26:C167 together into one cell for the ones that match "SB"

    I'm at: =IF(A26:A167="SB",(TEXTJOIN("",TRUE,C26:C167)))

    This will dump all the email addresses into one field that are marked SB.

    I am getting a #SPILL! error.

    1. I think I figured it out...not sure if it is the most efficient or best formula, but it seems to work.

      =TEXTJOIN("; ",TRUE,IF(A26:A167="SB",C26:C167,""))

  31. =IF(G3>H3,H3,G3)
    am using this calculation to identify if G3 greater than H3, but I also need the reverse if H3 <G3, needs to be value G3, unsure how to add this into formula
    Need excel to distinguish greater value over both columns
    Hope this makes sense!

  32. Hello,

    I want to highlight column A one color depending on specific name in column G of the same line.

  33. Hi, I am trying to write an if-formula where, if the value is true, the outcome should but 0, but if the outcome is false, a formula should calculate a value. So far this is what I have got: "=IF(F4="Yes",0,(G4+J4)-(E4+H4+I4))". However, this does not work. Is this idea possible or should I implement this in a different way?

    1. I got it! The answer was "=IF(F4="Yes";0;(G4+J4)-(E4+H4+I4))"

  34. Hello, good day!
    I need a formula for my sheet that automatically updates my cell as "Updated Recently" if the date I entered is within this week, if not it should be automatically update with just a blank.

    For example:
    [Cell1] Last Sale: March 10 (within a week) = [Cell2] Status: Updated Recently
    [Cell1] Last Sale: Feb 27 (Last week/last month) = [Cell2] Status:

  35. What shall I write in logic test,value true and value false while doing my ecxel program

  36. **Correction to my previous question: need help with this formula- If the date in cell W2 > date in cell Q2, then return the number that is in cell AB2, if not then return number in cell T2

  37. need help with this formula- If the date in cell W2 > date in cell Q2, then return the number that is in column T2

    1. Hi!
      All the necessary information is in the article above. Since the dates in Excel are numbers, you can compare them as numbers.

  38. I want help writing a formula where on an expenditure sheet there are two 'company names' which amounts spent ge assigned to. The formula I require is to automatically take the amounts from the other sheet and list the amount assigned to either company on diiferent cells under the heading of the company name.

  39. Hi. I need a formula to populate the name of the counselor assigned to a student based on a students last name. I have a list of student's last names on column G and I have the the counselors names on a different sheet within the same workbook. Please help. I got it to work if I place the counselors names on the same sheet where the student information is located but if I delete a student, it will mess with the formula.

  40. Hi, Im trying to find a formula to search from column D2 to D10 for an exact name if there is to print yes if not to print no.

    First name Last name
    1 John Smith
    2 Mike Hunt
    3 Sam Isaco

    So basically what I want to do is if the certain name and last name are found in these columns to print yes

    Is this possible?

    Thank you

    1. Hello!
      If I understand your task correctly, you can define a partial match of a word and a text string with the combination ISNUMBER + SEARCH functions.

      =ISNUMBER(SEARCH("Smith",A1:A20))

      I hope it’ll be helpful. If this is not what you wanted, please describe the problem in more detail.

  41. Hi, Can you please help me, in Excel if column A2 value= Column B value, then only compare column C value with column D value and provide result in column E.
    Example:

    1234 END 1234 CERIAL END
    1234 FORNT 1234 BACK FRONT
    1234 ARIAL 1234 GAME9 N/A
    1234 GAME 1234 GAME2 GAME2
    1234 GAME 6 1234 GAME8 N/A
    1234 GAME9 1234 GAME7 GAME9
    1234 GAME2 1234 FRONT N/A
    1234 GAME3 1234 CHANG N/A
    1234 GAME1 1234 END N/A

  42. Hi,

    I'm not sure if anyone can help with what I think should be a relative simple formula that I'm stuck on. I need to create and IF or an AND formula that will look at two arguments that both need to be be True, one argument is checking that a Date is =>2023,1,1 and another cell contains an exact text "Vacancy".

    I have managed to get the Date check to work, however I have no idea how to add the AND argument to check the text in the other cell, I currently have the following formula:

    =IF(A2>=DATE(2023,1,1),"Yes","No")

    The person should only be entitled to the payment if the Date is >=2023,1,1 and that the Role (text) in cell B2 is "Vacancy".

    Thank you for your help.

      1. Brilliant! Thank you so much for your help, this has worked perfectly. I could not work out where the AND should go. Thank you.

  43. How can i categorize the cell content based on the starting letter. (Example:- Different grade of fruits has code like a123, b123 etc., i want to categorize the fruits as "A grade" for the code that starts with "a".

    1. I have 3 options in source column instead of two so how should I do
      For example
      If IND2522 - it should reflect in colour as India
      If BNG2522 - it should be reflect as Bangladesh
      If PAK2522 - it should be reflect as Pakistan

      1. Hi! Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

      1. Thank for your prompt response Mr. Alexander

        i have list of materials in row A which has two types of material codes one type starts with alphabet like "S123, S234 and so on" which is semi finished and another code was only numeric it was finished goods. In row D i need the codes which starts with alphabetic should name as "Semifinished" and numeric code as "Finished goods". i believe that i gave you the clarity to derive the formula.

        1. Hello!
          This formula returns TRUE if the first character is a letter.

          =ISERROR(--LEFT(A1,1))

          I hope this will help, otherwise don't hesitate to ask.

          1. Yes, it's working but it will be convenient if the formula returns to any name instead of TRUE or FALSE.

  44. Logical Text in A1 Cell ,TRUE Value in A2 and FALSE Value in A3
    i write IF Function in A4 = IF(A1,A2,A3)
    but it doesn't work properly. it will prompt Error Massage (#Value!)
    so can i put LOGICAL TEXT in cell.

  45. Hello. Please help provide the formula for a cell L23 to either show "N" if less than a certain date such as 02/15/2023 and "N" if passed that date in A23, thank you!

    1. Hi!
      Pay attention to the following paragraph of the article above: Excel IF statement with dates.
      It covers your case completely.

  46. Hey Friends,

    Donno if this Forum works now:

    I am trying to figure out a formula for the following:
    I have 3 Columns : viz : A1,D1, L1 with text contents. And output expected in M1

    So if All of the 3 cells A,D,L are Blank, Then out put should be "Spare",
    If any of the 3 cells mentions : "In Stock", Output should be "In Stock",
    If any of the 3 cells mentions : "Faulty", Output should be "Faulty",
    Else if any columns has any text it should show " Mapped"

    1. Hi!
      Combine cell values and search for the desired text using the SEARCH function. Use a nested IF function to display values based on conditions.
      Try this formula:

      =IF(ISNUMBER(SEARCH("In Stock",A1&D1&L1)),"In Stock", IF(ISNUMBER(SEARCH("Faulty",A1&D1&L1)),"Faulty", IF(A1&D1&L1="","Spare","Mapped")))

  47. i need to calculate the hours of the roster of the month of each staff (M=6.5, E=6.5 , N=8, O=0) please help

  48. Hi!
    I am trying to get my IF statement to take a current number, and if it is over 40, bring it down to 40. If it is under 40 I want to leave it at 40.

    I have attempted the formula =IF(E10>40, 40, E10) I just don't know what to put in the false statement, to keep it at the current value it was at if under 40.

    Thanks for the help!

      1. Thank you!

  49. Hi,

    =IF(B1=5 and C1=3, "Good combination", how i can use this formula

    Kindly confirm.

  50. I'm trying to create a formula to help build a table for a student outcome report.
    A B C D
    1 Comm 1010 Comm 2010 Comm 3000
    2 Communication 2 4
    3 Critical/Creative Thinking 5
    4 Community Awareness 3 4

    If any text in Column A=Communication and any text in Row 1= Comm 1010, then show the number for that combination. In this example, 2 would be displayed.

    If any text in Column A=Critical* and any text in Row 1=Comm 2010*, then show the number for that combination. In this example, 5 would be displayed. I need to be able to use a wildcard for both text options.

    If there is no number in the cell, then leave it blank.

    The numbers will be sent to a different sheet. Right now, I have to sort both sheets so everything lines up. I am hoping there is a formula that will pull over the numbers and I don't have to sort anything.

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