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

  1. Is there a way to code a function in this example?
    IF a cell contains 1 word (of 3 choices) in A1, then I want the value in B1 to appear in C1.

    1. Hello Keith,

      You can enter the following formula in C1:

      =IF(OR(A1="word1", A1="word2", A1="word3"), B1, "")

      1. How can i do this for multiple cells and add them all together?

  2. Thank you. It is helpful. I was thinking about some free version of variation as well.

    Thanks!

  3. Quick Question:
    I wanted to match last names from two excel sheets, then select the values (DOB) to be ported to the other excel sheet. What would be the formula?

  4. =IF(N18<=5,"32A",IF(N18<=5,IF(H18="1x4Cx6","")))

  5. Hi can anybody Correct this Condition

    =IF(A3180,(A3+180),IF(A3>540,(A3-540),"")))

    1. Hello Pawan,

      Probably you meant this:
      =IF(A3>540, A3-540, IF(A3>180, A3+180, ""))

  6. I want create a formula with if condition i am depreciating the value by 33.34% for 1 st year & 2nd Year & 3rd year according to my % of depreciation from the 1st july'16 to 30th june'16 but its not working for current 2016, kindly check the formula & help me.
    AA Column type Z column has date Y Colume
    =IF(AA429="R",0,ROUNDDOWN(IF($Z$1-Z429<=365,Y429*100%,IF($Z$1-Y429<=730,Y429*66.67%,IF($Z$1-Y429<=1095,Y429*33.34%,1))),))

  7. Hi guys good evening!

    How to apply in excel the following formula:

    0 - 136 = tax exempted
    136 - 2500 = 14% tax
    >2500 = 350 plus 25% tax

  8. I can't figure out the "If" Formula.
    Cell B26 is blank, 0.00, or greater than 0.00
    Cell D26 = 970.53
    Cell E26 Formula, to be T1 or T9
    Cell F26 Forumla, to be an amount
    Cell G26 Forumla, to be an amount
    Need the following formulas....
    1) For E26... If B26 = nothing, or 0.00, then E26 = "T9" otherwise "T1". For E26 to be "T1", B26 needs to be greater than 0.00.
    2) For F26... If B26 = nothing, or 0.00, than F26 = D26 otherwise F26 is to be D26-B26.
    3) For G26... If B26 = nothing, or 0.00, then G26 needs to show a zero (not a blank), otherwise G26 is to equal B26.
    Thanks for your help.

  9. I am making a weekly schedule for 2 months. I have entered the days of the week in a column. I need that if the day of week be Monday,Wednesday, Friday then output A , and if it be Tuesday, Thursday, Saturday , then B. Please help with the command line.

  10. Cell A1 is calculated and gives a numeric value.(a time value)
    I have used IF function so that A1 can only show a maximum of 9:30 even if the calculated value is more than 9:30.

    A1 is then used by other cells to calculate other values.

    I want to be able to show the value in A1 like so :

    If A1 is equal to or greater than 9:30 then show cell value as 9:30

    If A1 is less than 9:30 then show that actual value

    Can anyone help ?

    Thanks

  11. I have a spreadsheet where column E represents the amount of money owed for a monthly payment and column K asks "yes or no?" (using a drop-down list) to whether or not a late fee ($50) should be applied. I'm having trouble creating an "IF" formula that would add $50 to the amount listed in column E "IF" column K answered "Yes". Can someone help?

  12. I have four values in four columns. If first column's value is greater than 0 and the second colummn is equal to zero and third column is greater than 0 and fourth column is equal to 0, i want to type pass in the fifth column. Else fail. Can anyone help to write a formula for this?

    1. IF( AND( $A1>0, $B1=0, $C1>0, $D1=0), "Pass", "Fail")

  13. Hi there, bit of a tricky one here. This works fine, but i have to do this for 11 colums, is there a way so shorten this code?

    ="Port: "&IF(AND(G2>100,G2100,G3100,G4100,G5100,G6100,G7100,G8100,G9100,G10100,G11100,G12100,G13100,G14100,G15100,G16100,G17100,G18100,G19100,G20100,G21100,G22100,G23100,G24<500),"23,","")

    1. ="Port: "&IF(AND(G2>100,G2100,G3100,G4100,G5100,G6100,G7100,G8100,G9100,G10100,G11100,G12100,G13100,G14100,G15100,G16100,G17100,G18100,G19100,G20100,G21100,G22100,G23100,G24<500),"23,","")

      1. ="Port: "
        &IF(AND(G2>100,G2100,G3100,G4100,G2<500),"A2,","")

        And if possible to shorten this, because writing it out for every row 23 time s is a drag

  14. Hai,

    i am looking a formula for calculating gratuity as basis of "OnDuty".
    i have found the formula to calculate the gratuity for slab basis. but now i am facing one issue, that while applying this formula to a text containing condition its been showing an error.
    1. =(IF(Q3-G3+1<=1825,(J3/30)*21/365*(Q3-G3+1),IF(AND(Q3-G3+1=1826),J3/30/365*28*(Q3-G3+1-1825)+(J3/30)*21/365*1825,IF(AND(Q3-G3+1=3651),((J3/30/365*35)*(Q3-G3+1-3650))+(J3/30/365*28*1825)+(J3/30)*21/365*1825,0))))

    2. =IF(H3="OnDuty",(IF(Q3-G3+1<=1825,(J3/30)*21/365*(Q3-G3+1),IF(AND(Q3-G3+1=1826),J3/30/365*28*(Q3-G3+1-1825)+(J3/30)*21/365*1825,IF(AND(Q3-G3+1=3651),((J3/30/365*35)*(Q3-G3+1-3650))+(J3/30/365*28*1825)+(J3/30)*21/365*1825,0)))),"")

    please reply

  15. =IF(BD2,"Not a Target", "Not a Target, BD2&": "&BC2)

    I'm not sure what I am doing wrong? Any ideas?

    1. Hi Sarah,

      The syntax of the Excel IF function allows 3 arguments, while your formula has 4. If you can provide some details about the source data and expected result, I will try to help.

  16. Thanks for clear explanations on this IF problem.

  17. Been looking online and trying for hours now and have failed to find a solution to my desired outcome in my workbook.

    I have column A with order numbers that look like this, a3er-k8uy. Every order has a base fee of $4.50 which I manually input into column B. I would like column B to fill in the $4.50 any time I input an order number. Is the IF formula the one to use, if so how?

  18. I have a formula that sums my WIP. I want an IF formula to help me mark Error if that sum is over $0.00 and balanced if its $0.00. I have tried but my formula will not pick up unless I manually type 0.

  19. Hi, I missed a symbol in the example I provided with my query. Correct example for the formula I am aiming to apply in cell B1 is =IF(AND(A1"",B1=""),"Display Error Message","Allow selection from list of values for B1")
    Thanks

  20. Hi,
    I am trying to display an error message using IF function.

    Data for one of my columns (say column B) is a list of value. Depending upon the value selected by the user in Column B, I populate the values in column C using the LookUp function.

    Column A of my worksheet has a date and if user enters a date for a record in column A, I want the user to select one of the values(from drop down list) in column B. If the user doesn't enters the value in column B and leaves it blank, I want to display an error message.
    e.g. =IF(AND(A1"",B1=""),"Display Error Message","Allow selection from list of values for B1)

    Pls guide. Thanks

  21. I'm creating time sheets in Excel. I would like for a cell to automatically populate "8" if another cell contains any one of several dates. I am able to use the following formula successfully for one date:

    =IF(O9=DATEVALUE("12/23"),8,"")

    However, I would like to use multiple dates. For instance, show "8" if cell O9 contains 12/23, 4/14, or 11/24. Otherwise, leave the cell blank.

    Any ideas?

    1. Sorry this a cut and paste from me elsewhere. Check if the cell does/does not exist in a named range of cells containing your exception dates.

      Hi, sorry I don't have a spreadsheet in front of me to syntax check.

      Eg.
      IF( OR( A1="Football" , A1="Basketball", A1="Hockey"), "Sport" , "Something Else" )
      -OR-
      I often flip my IF statements to check for Errors or Exceptions first.
      Eg.
      Define an area in Formula Tab, MySportList=$L$31:$L$59
      Fill these cells with your sports.
      IF( ISERROR( VLOOKUP( A1, MySportList, 1, false)), "Something Else", "Sport")
      # IF TEST is, if you get an error when trying to lookup the contents of A1 from your list of Sports in cells, L31:L59, then display "Something Else", else display "Sport".

  22. if A1 is 0 print 0 and if B1 is 0 print 0 and if ((A1 and B1)>0) print =A1+B1

    1. IF( OR( A1=0, B1=0), 0, IF( AND( A1>0, B1>0), SUM(A1+B1), "A or B is less than Zero")

  23. Hi Svetlana Cheusheva,

    I am facing issue with this formula and need your guidance.

    i am preparing a sheet which contains Team attendance and would like to use IF condition. For ex: if a person is coming in the morning shift he has to number as 1, if afternoon it's 2 and Night it's 3, Leave it's 4. How can I write a formula for this. Please advice me on this.

  24. hello Emmanuel again =IF(D8"",D8+8,"OFF") this formula works on a same sheet but picking the source from a different sheet doesn't give me the correct answer example =IF(Sheet1!D3"", D3+8,"OFF". it only gives me 8 without adding the figure in the cell. can you help

  25. I am looking for some help and guidance. in Excel 2007

    basically I have 3 cells. In one cell I have a calibration date, In second cell I have due date, and in third cell i have frequency of calibration i.e. quarterly, annually and 2 years. Now at the moment I have to manually change all the dates whenever the due date is up, what I would like to do, is to be able to change the calibration date and for the due date to change automatically based on the frequency of calibration.

    Could someone please help me with this issue? Many thank

  26. Hi,

    I need a help.

    Assume that this values are in one cell "'C3, C4, C6, C10, C11, C12, C16, C17, C18, C22, C23, C24, C30, C31, C33, C34" .

    I need a formula that whether C17 is present in that cell or not.

  27. i want to create a formula where =IF(D8"","+8","OFF") where if not blank add 8 and if blank put off. But the formula is not given me the required result

    1. Hello Emmanuel,

      Here's the correct syntax:
      =IF(D8<>"", D8+8, "OFF")

  28. Hello Svetlana,

    I have a conditional formula in Column F and am seeking a conditional formula for Column G. My goal is for Column F to affect Column G, dependent on the parameters I give Column G. I would like for Column G's logic to be as follows:

    If F1 is >=6 concurrently <11 [then] if true, G1 = 1. If false, G1 = "".

    Thank you for your valuable help.

  29. I want red font color if the logic is false.
    Pls. guide me.
    with thanks

  30. I have a date format in column e and in column f I have put a formula for it to automatially update it to 3 years later by adding 1095 to column e. Now, I am trying to get column a to turn red 60 days before column f is mature. I have tried conditional formatting but for some reason it doesn't work.

    1. Hi, sorry I don't have a spreadsheet in front of me to syntax check.

      Checks:
      Column E has numbers that display as text and not text "12/09/2020".
      Column F should be the formula =E1+1095 and display 12/09/2023.
      Format:
      Condition Formatting on Cell Range =$E$1:$E$51 as a formula option.
      IF( TODAY() >= (F1 - 60), TRUE, FALSE)

  31. Is it possible to use OR commands in the logic function?

    Ie, something along the lines of

    =IF(A1="Football" OR "Basketball" OR "Hockey", "Sport", "Something Else")

    Thank you in advance

    1. Hi, sorry I don't have a spreadsheet in front of me to syntax check.

      Eg.
      IF( OR( A1="Football" , A1="Basketball", A1="Hockey"), "Sport" , "Something Else" )
      -OR-
      I often flip my IF statements to check for Errors or Exceptions first.
      Eg.
      Define an area in Formula Tab, MySportList=$L$31:$L$59
      Fill these cells with your sports.
      IF( ISERROR( VLOOKUP( A1, MySportList, 1, false)), "Something Else", "Sport")
      # IF TEST is, if you get an error when trying to lookup the contents of A1 from your list of Sports in cells, L31:L59, then display "Something Else", else display "Sport".

  32. Hi,
    I need a formula as per below scenarios, can someone help on this:

    column 1 = Yes / NO
    Column 2 = Rural / Urban
    Column 3 = Balance dues in number months shown

    below is the requirement :

    Column 4 = if line item says Yes and Urban and no. of months due is 2 then 4 should be the resultant. second secenario if line item says No and urban then the 0 should be the resultant in the same cell.

    Thanks !

  33. Hi Gene

    can you help me develop IF syntax for:

    Youth (64)

  34. Hi All,

    I have formula in the Cell Z24 i.e. =((V24-L24)*E24)-AD24-AB24-AE24-AC24. Now my requirement to this is when CELL "E24" is "Not ZERO" or "BLANK", then it should process the formula =((V24-L24)*E24)-AD24-AB24-AE24-AC24 else, if CELL "E24" is "ZERO" or "BLANK", then the value in Z24 should be "0".

    Any help pls?

    1. Hi, sorry I don't have a spreadsheet in front of me to syntax check.
      I often flip my IF statements to check for Errors or Exceptions first.
      Eg.
      IF( Value(E24) = 0, 0, CALCULATE)
      -OR-
      IF( OR( E24=0, Trim(E24)="", ISERROR(1/E24) ), 0, CALCULATE)

  35. Hi, so far I have this formula in cell I3 which works. My problem is that I don't know what to add to tell I3 that if D3 is blank then I3 should be blank too. I hope you can help

    =IF(D3>100,"50",IF(D3<100,"30"))

  36. I need your help, I have to calculate the interest amount on bases of delayed dates. Ex. 500 days. Base amount-Rs 10,000

    Interest rate slab mentioned below
    <180 days-18%
    365 days-30%

    So, I have to pay Interest for first 180 day@18%,Second 185 days@24%, remaining @ 30%.

    Can you give the excel formula for the above case.Please

  37. Hi. Please help.

    If($CC$2="AC",($CC$5*AC6),IF. . . . .

    That is my formula. How do I get that if cell CC2 is not equal to anything, that the cell then stays empty. Cause if I put in "", the return value is 0, and it has to return an empty cell and not 0.

    Thanks

  38. if A and D are both less than 75: 0
    if A is greater than or equal to 75 and D is less than 75: Calculate (A — 75) = X value.
    if D is greater than or equal to 75 and A is less than 75: Calculate (D — 75) = A/D value.
    if A and D are both greater than or equal to 75: Calculate [(A — 75) + (D — 75)] = A/D value.

  39. Hello everybody,

    I have a task, please help me to prepare it in excel. in one sheet column A, I have some barcode numbers and in coloum B i have its text name. In another sheet I want to make something like if i scan a barcode sticker with scanner and if it is present in Column A, it must display its text value from column B instead of number.

    thank you

  40. Hi, how can I extract a specific data based on condition from a range of cells, like below
    A1 B1 C1 D1 E1 Result
    Pass Pass Pass Fail Pass Fail

    Problem Statement: I want to print 'Fail' in result cell if any of cells from A1-E1 has FAIL in it, or else Pass if there is PASS in any of the cells from A1-E1.

    Any help is appreciated

    1. Hi Sash,

      You can use the following formula:

      =IF(COUNTIF(A1:E1, "fail")>0, "Fail", IF(COUNTIF(A1:E1, "pass")>0, "Pass", ""))

      1. Hi, how can I extract a specific data based on condition from a range of cells, like below
        A1 B1 C1 D1 E1 F1 Days
        35 39 32 34 36 42 Share price
        I want to know whether today share price is greater than last 5 days.
        If it is greater then alert message needs to be created "YES".
        It is easier for 5 days period however in case of 15 days or 30 days or 45 days, it is difficult to track.
        Need formula for daily tracking of stock for period of 15 days/30 days/45 days.

        1. Hello!
          You can calculate the maximum value of the 5 preceding cells in a row using the formula

          =MAX(INDIRECT(CELL("address", INDIRECT("R2C"&(COLUMN(INDIRECT(CELL("address",L2)))-6),0))&":"& CELL("address", INDIRECT("R2C"&(COLUMN(INDIRECT(CELL("address",L2)))-1),0))))

          R2 means row 2. You can change the row number.
          L2 - cell with the current value.
          You can learn more about INDIRECT function in Excel in this article on our blog.
          If something is still unclear, please feel free to ask.

  41. Hi cheusheva,
    I need to enter a formula that, if the given Date is lesser than or equal in a range of date exists; it should count the corresponding value of that particular date which is lesser than or equal, can you help me, I tried entering formula like here,
    ex: IF(A2<=D2:D234,COUNTIF(E2:E234,B2),""), but this isn't working...!

  42. if bob starts at 10am and ends at 12pm
    if sue starts at 10am and ends at 1pm

  43. I have a problem. it's a time sheet and across the top row is the times from open to close. next few rows down is the start and end times of all the workers from the time they start working to the time they end their shift. I need a formula to calculate their hours per work shift.

    Example of what I am working with

    A B C D total
    10am 11am 12pm 1pm
    bob start end 2
    sue start end 3

    1. I've tried using this formula but it won't add the texted cells, it just shows a 0.

      =SUM(IF(ISTEXT(C5:K5),1,0))

  44. Hi Can you please help me.

    I have a data set where the question asks: How many of the above products are produced in Namibia?

    The options in the questionnaire were: I don't know, not applicable and giving specific numbers such as 1 or 100.

    Butt the results of the data: came with different formats i.e. 1 to 10, or +-100. who do i evaluate those results in a data set of 450 cases to get the total number of products?

  45. hi Svetlana,

    could you please help me to get this below readings to nearest ten. for

    Example
    4204 to 4200
    5403 to 5400
    8439 to 8440
    8360 to 8360

  46. can you help me to get nearest 10

    for example 1844 it should need 1840
    and 1846 it should come automatically to 1850

    like this so plea help me to to get this formula

  47. how do i indicate a value for a particular month:

    if month=January, above cell + 31 days else above cell + 30 days

    What is the syntax for this function ?

    1. Hello Dharmesh,

      You can use a formula similar to this:
      =IF(month(A2)=1, A1+31, A1+30)

  48. Hello Svetlana,

    I wish to have something like this
    If M8 from 0 to 10% then 1
    If M8 from 10% to 20 % then 2
    If M8 from 20% to 30% then 3
    If M8 from 30% to 40% then 4
    If M8 more tjen 50% then 5

    So is this posibile in excel?
    Thank you in advanced

  49. I HAVE A FORMULA IN Cell J6 and I have another formula in g6. WHEN I ENTER ANOTHER FORMULA IN K6 =IF(SUM(G6*J6),G6*J6,"") i WILL GET RESULTS ONLY WHEN THE CELLS HAVE NUMBERS. BUT WHEN CELL J6 OR G6 IS EMPTY I GET THIS IN CELL K6 #VALUE! INSTEAD OF A BLANK CELL CAN YOU HELP ME

  50. hi,
    i have characters in row "A" in drop down box.
    i just need to display value depending on different products in row "A"
    for different products i have different value for multiplication . how can i do that on conditional bassis. suppose if i choose product A1 then it should choose multiply by 2, if i choose product "B" it should be multiply by 3 and so on

    1. Hi!

      Assuming the dropbox is in cell A1, and the value to multiply in B1, the formula goes as follows:

      =IF(A1="a",B1*2, IF(A1="b", B1*3, IF(A1="c", B1*4, "")))

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