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

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

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

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

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

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

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

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

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

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

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

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

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

  13. Hi Gene

    can you help me develop IF syntax for:

    Youth (64)

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

  15. 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"))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  31. I am trying to figure out how to use excel to figure my time sheets. I have a computer program that will send me a print out that looks like this, I can import in excel and it would look like this..
    Example:

    CARRIE EVANS - CLERK
    Punch In Punch Out Reported Tips Time (Hours)
    Thu, 10-20-16, 6:50 am Thu, 10-20-16, 2:03 pm 0 7.217
    Fri, 10-21-16, 6:50 am Fri, 10-21-16, 2:00 pm 0 7.167

    I need an excel spreadsheet that I can Import this into and figure to the 15 min increments. Punch In is one cell and Punch out is one cell. I wish it was day, date, time all in different cells, but that is not the way it imports. Can anyone help me with this. Thank you

    1. each cell looks like this
      Punch in
      Thu, 10-20-16, 6:50 am
      Punch Out
      Thu, 10-20-16, 2:03 pm
      Reported Tips Time (Hours)
      0 7.217

  32. Please Help Me If Function below the condition

    1. From the basic salary of Rs 8250 to Rs 9700, Rs 4500 minimum basic salary at the rate of 50%.

    2. Base salary up to Rs 16,000 from Rs 9701, Rs 4800 minimum basic salary at the rate of 45%.

    3. From the basic salary of Rs 16001 to Rs 35500, Rs 7000 minimum basic salary at the rate of 40%.

    4. Rs 35501 and above base salary, up to 35% of the minimum wage of Rs 13800.

  33. hi,
    I am doing a template for quiz competition in excel, in excel book first sheet is for participants there is a questions and the seperate cells for typing ans
    if the answer is correct the mark will appear in the second sheet in the respective cells
    for this i am using if condition
    for ex: ans for 1st question "ABC" which enroll second sheet
    incase the participant gives the input as "BCA" instead of ABC how can i do

  34. Hi Svetlana

    Need a help to populate status on C3 based on A1 & B1 value on project tracker

    If Cell A1 & B1 is blank leave C3 value as Blank
    If Cell A1 have start date show C3 as "In-Progress"
    If Cell B1 have end date show C3 as "Completed"

    Thanks.

  35. Hello,

    How can i pull out birthday's of employee automatically using current date, for example, i have the list of the employee's with me , i just want the list to automatically pull out the employee's name who have their birthdays today.

    Thanks.

  36. Good day Svetlana,

    I have this simple formula,

    =if (A1B1, the function return "Failed".

    How can Excel compare a number with a string (5<N/A)?

    5<N/A should produce #Value or #Error...

    Kindly help.

  37. Hi! can you help me with a formula? i have sheet wherein C1=B1 multiplied to A1 but i want C1 to be blank if B1 is blank and C1=B1 if A1= 0 or blank..

    thanks

    1. Hello Clark,

      Try this one:

      =IF(B1="", "", IF(OR(A1=0, A1=""), B1, ""))

  38. I am trying to do an if formula for a Y n that if it hits a yes it then goes on to do a sum... but I cant get it to work, am I using the wrong formula
    =IF(J7="Y",P7/5,IF(J7=n,"0"))

    Please be kind as I am a novice

    1. Hi Peej,

      You need to enclose all text strings in double quotes, but not numbers:

      =IF(J7="Y", P7/5, IF(J7="n", 0, ""))

  39. Hi Svetlana
    I want to group golf scores into birdies, pars, bogeys and double bogeys. I have my golf scores in cells c4 - u4 and the course par for each hole is in c3 - u3

    eg hole 1 (c4) my score is 4 and par (c3) is 4 so I need a IF formula for cell k20 which is to add up all my pars for the round (18holes)
    If I scored 6 pars (6 times where my score in row 4 will equal the par for that hole in row 3)

    I want to do the same to record birdies (score is 1 less than par), bogeys (score 1 more than par), dbl bogeys (score 2 more than par) etc
    using different cells

    All the details of number of birdies, pars, bogeys and dbl bogeys will be using the data contained in cell ranges c4 - u4 and c3 - u3.

    Hope you can help

    1. Hi Murray,

      To make things easier for me to understand, can you please send a sample sheet we well as expected results to support@ablebits.com, or copy a piece of data to Excel online and post a link here?

  40. I HAVE THIS FORMULA IN J6 =IF(ISNA(VLOOKUP((P4),'15-16'!$A$3:$F$2545,6,FALSE)),"",VLOOKUP((P4),'15-16'!$A$3:$F$2545,6,FALSE)) THIS FORMULA WORKS GREAT. BUT WHEN I ENTER ANOTHER FORMULA IN K6 =IF(SUM(G6*J6),G6*J6,"") THIS FORMULA ALSO WORKS BUT WHEN THERE IS NOT TEXT, THE COLUMN IS SUPPOSED TO BE BLANK, INSTEAD IT BRINGS BACK #VALUE! THE FORMULA IN K6 IS LOOKING AT THE FORMULA IN J6 INSTEAD OF THE RESULTS IN J6. CAN YOU HELP ME

  41. Need Help please... Thank You in advance.

    I have 3 columns.
    Column A - list of country
    Column B - Yes or No
    Column C - country (example in C1="PERU")

    Column D - result should be "Yes" or "No"
    - if C = "PERU" and if all the data with "PERU" in column A has value
    of "YES" in Column B, then "Yes", otherwise "No"

  42. Hi

    I'm trying to figure out a formula using the function IFs where I have 3 conditions to return "e.g. 3 payable commission roles 10% 12% & 14%" - But I am not sure how to write this all in small function in excel !
    This is what I am after "between/equal 100% & 109% then multiple the revenue by 10% , between/equal 110% & 119% then multiple the revenue by 12% ,EQUAL or greater than 120% then multiple the revenue by 14%, return £0 if less than 100% " this is what I have done so far :
    A1 % to target
    B2 £ Revenue
    =IFS(A1=100%,"B2*10%",A1109%,"B2*10%", .....)

    I would really appreciate your help.

    Thank you
    Hasnaa

  43. I have different dates in column B1,B2... and amount in G1,G2... for which i have to calculate service tax pertaining to that date.
    I'm using below formula which is not calculating properly.
    =IF(B5<1/6/2015,G5*12.36%,IF(B5<15/11/2015,G5*14%,IF(B5<1/6/2016,G5*14.5%,G5*15%

    Please let me know in which format the date should be in formula as well as in column B

    Looking for your reply..

  44. Hi Svetlana

    Need a help

    If Cell A1 & B1 have no date Show C3 as Blank
    If Cell A1 have date show C3 as In-Progress
    If Cell B1 have date show C3 as Completed

  45. hi dear ,
    i have data sheet of fragrance product ,trying to find sizes from column to past in to aother column
    for instance column A1 hsd discription of perfume name and its sizes such as 1. oz , 1.5 oz , 2. oz and so on....i would like to just take ""sizes"" from column A1 to collum A2. what would the formula to do this coz i got 10000 products on sheet .
    *
    sizes are about 15 to 20 diffrent types on entire sheet or value which needs to be found and past in to specific collum . how to write formula for this action . thx .

  46. Hi I have query please
    In A2 is the status if I put date in B2 the A2 put "Requested" and if I put date in C2 the A2 change "Delivered" and if I put date in D2 the A2 change "Released".. Please help me thank you..
    What formula can I used.

  47. Hi good day,
    What formula can I used, example if I put date
    Status Request Delivered Released
    Request 10-5-16
    Delivered 10-5-16 10-10-16
    Released 10-5-16 10-10-16 10-15-16

    Please help. Thank you :)

  48. i am trying to get a result back from a cell that has a formula in another cell. =IF(AND(P48),$X$11,""). the results of this formula will be a number. the problem is that when put another formula (=IF(AND($Z$11>0,$W$11<0),$X$12,"")) in another cell it sees the formula not the results of the formula. how can I get excel to see the actual results in stead of the formula.

  49. Hi,

    I am trying to figure out how to format this formula. I need to create a formula that if either of the cells J3 or N3 are blank then S3 is 0. If none of the cells are blank, then I want S3 to be N3-J3

    Any thoughts?

  50. Hi, i was wondering is there any formula in excell that will be able to help me with the following. if i put in a value from 1-10 the following must happen, if i enter 1 it must calculate to 12 and 2 must go to 10 and 3 to 8 and so on, and it must calculate over a few cells.
    i hope you wil understand what i said here.

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