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

  1. Dear Mam,

    I am Working as Business Analyst. how can i give a ranking to the companies based on their MAT score with IF function.

    please clarify

  2. I am working on a spreadsheet for a game challenge. I have a list of options: Baby, Child, Teen, Young Adult, Adult. The values are respectively: 0, 3, 16, 29, 49. I'm unsure how to write an IF function to add an option from the list's value + another cell that will be filled in. I think it should be =IF(A1="Baby", 0) But how would I put all the options in there? Basically, how would I make it so that whatever option is chosen, it would return the right value and then add it to the cell?

    1. Hi Wolfy,

      This can be done by using nested If functions, e.g.:

      =IF(A1="Baby",0, IF(A1="Child",3, IF(A1="Teen",16, IF(A1="Young Adult",29, IF(A1="Adult",49,"")))))

  3. Hello, I just ran into a problem with a formula i had help on before. I have 5 vehicles that i use in a spread sheet. i need a formula that will prevent from incorrect information because of odometer numbers running together. i use another spreadsheet with additional vehicles and the odometer readings are similar. =IF(C14>=174121, 15, IF(C14>=227425, 5, IF(C14>=208012, 21, IF(C14>=143916=72700, 9, 0)))))
    #2 odometer is at 143916 #5 227425 #9 72749 #15 174121 #21 208012 Please help, thank you for your time, very much appreciated!

    1. Hello, I believe I figured it out--- =IF(C33>=227425, 5, IF(C33>=208012, 21, IF(C33>=174121,15, IF(C33>=143916, 2, IF(C33>=72700, 9, 0))))) Formula in the correct sequence resolved problem, if incorrect, please let me know. Thank you

      Reply

      1. Yes, the updated formula is correct. Putting logical tests in the correct order is critical because as soon as the first condition is met, other logical tests are not checked.

  4. Hi Svetlana. Thanks for the last reply, it was very helpful. However, I have a new problem I am struggling with.
    I have a list of names in column A and B and I want see all identical names as "true" in column C. I have only managed to make an if-function which compare e.g. A2 with B2, but what I would like to do is to compare A2 with the whole range of names in column B. Something like =IF(A2=B2:$B$5626, TRUE). This does not work for me for some reason, do you know why?

    1. Hi Andreas,

      The IF function cannot compare ranges. I think you can use the following formula:

      =IF(COUNTIF($B$2:$B$5626, $A2)>0, TRUE, "")

  5. Please help, I need my formula to say if age is between 25-30 then its a certain cell, if its 31-40 than its another cell. how can I write it?

  6. Hello,
    How can I assign a number to a text value and then add it?

    Data Validation is present in A1, A2 & A3
    Yes, No, Maybe are the values

    I want to assign Yes=1, No=0; Maybe=.5 and then be able to add those values,

    Example:
    A1=Yes (1)
    A2=No (0)
    A3=Maybe (.5)
    Total should be 1.5

    Thank you in advance for your help!

    1. Hello Michelle,

      You need to add a column for the formula that will assign a number to the values in column A:
      =IF(A1="Yes",1,IF(A1="No",0, IF(A1="Maybe",0.5,"")))

      Copy it down the new column to get a number for each cell in column A. Then you can use the SUM function to add the values you get.

  7. Светлана, would you be so kind to give me a hand on the following please? Assumption, in Sheet1 I have A1: toiletries ; A2: washing liquids A3: powders A4: toiletries; A5: conditioner etc. In Sheet2 I have B1: washing liquids; B2 powders, B3: shampoos; B4: toiletries; B5: shampoos etc. I Sheet2 I also have in C1: 213; C2: 325; C3: 564; C4: 912; C5: 487 etc.

    My objective is: In cell F1 to have the following result -> If value in A1 (sheet1) matches value in B1 (sheet2), then return value from C1 (sheet2).

    You help is very much appreciated. If you need more clarification on this matter please let me know. Зарание спасибо. Alex

    1. Hi Alex,

      If my understanding of the task is correct, you can use the following formula:

      =IF(Sheet1!A1=Sheet2!B1, Sheet2!C1, "")

      1. Светлана,thank you for your prompt response. Actually, I have realized the objective I have outlined is entirely incorrect. The actual output is: If VALUE in B1 matches the VALUE in the range A1:A5, then return the VALUE from C1. Correspondingly, when formula goes to B2 it has to check the range A1:A5 and if there is a match it returns the VALUE from C2.
        Apologies for the confusion caused.

        1. Светлана, no need to bother. I have managed to figure it out. Thank you anyway! Best Regards, Alex

  8. Hi,

    I have 3 column A, B,C and if A=B=C is Thrue, if not is False

    Please can you help?

    Thanks,

    Loredana

  9. Hi,

    I need help trying to correct this formula.

    =IF(OR(SUM(G8:R8)=0,(D7+F8),(SUM(G8:R8)0)),(D7-E8))

    I am trying to have it read
    if the sum of G8:R8 = 0 then add D7 + F8
    if the sum of G8:R8 does not equal 0 then Subtract E8 from D7

    However, it currently only Subtracts E8 from D7

    1. Hello Karen,

      You can use the following formula for your task:
      =IF(SUM(G8:R8)=0,D7+F8,D7-E8)

  10. Hi,
    I am trying to use the IF formula, but need it to have more than two options, and I can't make it work. Please can you help?
    e.g.
    Grades are listed in Column B of the sheet. Then in column C I want to add the grade description.
    If Column B = A, then I want column C to say Good.
    If Column B = B, then I want column C to say Medium.
    If Column B = C, then I want column C to say Bad.
    When writing the formula please use cell B2 and C2 as the cells that the data is in. Thanks
    Please can you advise the formula?

    1. Hello Anna,

      You can include several conditions in one formula the following way:
      =IF(B2="A","Good", IF(B2="B","Medium", IF(B2="C","Bad","")))

      You need to enter the formula in C2 and copy it down to apply it to the cells below as well.

  11. Hi Carlos,

    Explanation of the formula -
    ROUND(VLOOKUP($O3,tbl_Premiums,5,FALSE)*(T3+U3+V3),0)

    Refer to number in cell O3 for a the matching number in the table "premiums" column 5 and if it matches, multiply sum of Cells T3,U3 and V3. The end result to be rounded of to zero decimal points.

    1. Thank you very much Ramki. I really appreciate you help

  12. Hello,

    I translate this formula but I am not 100% sure if I am right. I was wondering if you can help me with it.

    A) =IF(OR($J3=99,$J3=98),CC3,VLOOKUP($I3,tbl_wages,6+$J3,FALSE))

    The IF(OR function means that if either of those two conditions are true ($J3=99. $J3=98) in my table, then my if function will give me my true result. On the other hand, VLOOKUP is looking for I3 and the next argument is that is looking for that information in the wages table or reference table and the final argument is telling me what do I want when I find I3 in column 6 and in this case it would be False

    Thanks,

  13. Hello,

    I was wonderinf if you could help me translate this formula:

    B) =ROUND(VLOOKUP($O3,tbl_Premiums,5,FALSE)*(T3+U3+V3),0)

    Thank you very much,

    Carlos

  14. Hello,
    I am creating a spreadsheet that returns the placement in a contest by percent. What I would like is a formula that tells me which place the resultant percentage (col G) is in. Col G has the following formula:

    =LARGE('Data Entry'!$E$3:$E$50,1)
    and ranked the percentages for me.

    Column B is where I am wanting to show placement.
    Column C returns the name of the competitor.
    Column A, I added the following formula to show duplicates in Column G:

    =C4&" "&COUNTIF($C$4:$C$52,C4)

    Columns D-F are the data entry cells for each competitor and result in the % in column G.

    Is there a way to show the placement (Col B) automatically by looking at

    Col G (%), but also taking into consideration if there is a tie (Col A shows second occurrences).

    ?

  15. Hi,

    If the cell A1 is more the 45 to add 15 and if A1 is less than 45 to times/multiply by 1.2

    Please if anyone could kindly help which formula i would have to use

    Many Thanks,

    Abe

    1. Hi Abe,

      Here you go:
      =IF(A1>45, A1+15, A1*1.2)

  16. I'm working on Address Labels and want to save time on typing the zip codes. I want to say If Logan, 84321, If Smithfield, 84335, If Hyrum, 84319 I want to do If's for 6 towns. Any advice on how to do it?
    Thanks

    1. Hello Johnnie,

      You can use a formula with nested IF function listing all 6 options, e.g. if the cities are in column A, it would look the following way:

      =IF(A2="Logan",84321, IF(A2="Smithfield",84335, IF(A2="Hyrum",84319,"")))

  17. Hi,

    Make separate column for name and Phone no.
    Example : column F for names and column G for phone no. (You Can use any column for names and Phone no)

    Use the below formula,if any column does not have phone no. but has name of the person. When your using this formula it will show as PHONE NO REQUIRED.
    formula.
    =IF(ISNA(VLOOKUP(A1,F:G,2,FALSE)),"phone no. requred",VLOOKUP(A1,F:G,2,FALSE))

  18. Hi
    i have 5 name and i am use if formula for phone number plz suggest

    like

    name is neeraj so number is 111 & select ravi so number is 2222

    =IF(K2="Neeraj","1111","Number Required")

    1. Hi,

      Make separate column for name and Phone no.
      Example : column F for names and column G for phone no. (You Can use any column for names and Phone no)

      Use the below formula,if any column does not have phone no. but has name of the person. When your using this formula it will show as PHONE NO REQUIRED.
      formula.
      =IF(ISNA(VLOOKUP(A1,F:G,2,FALSE)),"phone no. requred",VLOOKUP(A1,F:G,2,FALSE))

  19. Hello Swetlana,

    I was wondering if you can help me translate this formula:
    =IF(ISBLANK(C12),"",IF(ISNA(VLOOKUP(V12,tbl_PatternCode,6,FALSE)),"new",VLOOKUP(V12,tbl_PatternCode,6,FALSE)))

    1. Hi Carlos,

      1). its very simple range of column "c", Blank cell inside "c" column. it will show Blank only.
      2). if data in "C" column cell ,"VLOOKUP" formula applicable (if "#N/A" will come it showing "NEW")
      3). in "Vlookup" compare to "V12 column to tbl_PatternCode in '6' column"

      1. Thank you very muchhhhhh

  20. =if(L2=A, '1','0')

    1. Hi Syed,

      =IF(L14="A","1","0")

      1. =IF(L2="A","1","0")

  21. if weight is 0.001 to 2.000 Kg = 10 Rs & above 2.000 per kg 2 Rs.

    1. Hi Sunil,

      u can use this formula
      =IF(AND(I22>=0.0001,I22<1999.99),"10","2")

  22. =if(I22,"2")
    Please help function is not working

  23. Hi,
    How to use IF statement....

  24. I have the following:

    IF(TODAY()<=DATEVALUE("03/15/16"),TRUE,FALSE) which is working fine. I rather not make reference to the year so that I don't have to change the formula every year. Any ideas? I've tried to use a cell reference instead of TODAY() but the year is always present. I also can't seem to get around having the datevalue be MM/DD/YY.

  25. Where we can get the works using excel (work from home) any idea please send me the details.

  26. can you use "OR" in If formulas?

    i.e if a cell has values LV1 or LV2 (Either or)

    True: "OK"

    False: "Invalid"

    1. Hi Johnny,

      Sure, you can. The formula can look similar to this:

      =IF(OR(A1="LV1", A1="LV2"), "OK", "Invalid")

  27. Hi,
    I am using the German version of Excel, I want to add ">0" (bigger than zero)
    wit this formula,
    Can someone help me please how to do it

    Thank you
    =SUMMEWENN(C11:C47,"Handy",G11:G41)
    I have allready tried so it is not working
    =sumif(C11:C47,"Handy",G11:G41,">0")

    1. Hi Nabi,

      Firstly, because you have 2 conditions, you need to use the SUMIFS function that allows for multiple criteria. And secondly, the ranges should be of the same size. You also need to specify the sum_range.

      If you want to count the cells based on 2 conditions, then use the COUNTIFS function like:

      =COUNTIFS(C11:C47,"Handy",G11:G47,">0")

      1. Thank you very much for your help it was useful but it counting the numbers of the name repeating not the amounts in the cells.

  28. Hi Svetlana. Can you please help me with an If statement I am trying to create for a data set? The condition is that if the following names are within a specific column, then label it "pricing" in the exisiting cell or else if none of these names exist within that column then call it "contracting". So For example, IF (B7="Bob","Claire", "Roger")= "Pricing" OR "Contracting". Something along those lines..

    1. Hi Safah,

      witch name coming under "Pricing" u make one column(example,"Bob","Claire", "Roger" this name in C column),and compare to B2 and "Pricing" column u are result will come..

      formula =if(B7=C:C,"Pricing","Contracting")

  29. Hi Svetlana. Can you please help me with a formula? I want a cell to return the word "Write-Off" if the cell is bettween -$1 and $1. However the formula that I have doesnt work. =IF(AND(B2>1, B2<-1), "WRITE OFF", ""). Thank you.

    1. hi Sue,

      use this formula your result will come...
      =if(B2<2,"WRITE OFF","")

      1. Hi Sue,

        Your used the right approach, just swap the numbers in the AND statement:
        =IF(AND(B2>-1, B2<1), "WRITE OFF", "")

        If you want between -$1 and $1 inclusive, then use the following operators:
        =IF(AND(B2>=-1, B2<=1), "WRITE OFF", "")

  30. please can any body advice:
    when need c1= a1 or b1 (if b1=0 then c1=a1)

    1. Hi Mukul,

      Here's the formula for C1:

      =IF(B1=0, A1, B1)

  31. I have various cells with different dates, going along I want to highlight cells that have a difference in date greater than 6 weeks between them

    IE.

    A B C
    1 Review 1 Review 2 Review 3
    2 01.01.2015 01.02.2015 01.12.2015

    So review 3 date I want to be highlighted as there more than 6 weeks between them.

    I found one which is =today()-C3>42 but that’s not right is it coz that’s working from today… right? BUT if I change it to =-B2-C2>42 I thought that might work but it only works on one cell (I’m obvs changing to B3 etc.) I’m soooo stuck!

    1. can u pls sand me work sheet "hemanth923@gmail.com"

      1. hi Daisy,

        first u convert to days like below formula =DAYS360(A2,TODAY())
        386 356 56 32
        01-01-2015 01-02-2015 01-12-2015 25-12-2015

        and down cell u use this formula =HLOOKUP(IF(42<A1,A1),A1:A2,2,FALSE)

        42 days above it will so date, 45 days below it will so #N/A

        i thing this is method for u are result

        1. ah thank you, I will send it to you now!

          1. Hemanth, did you get my email?

  32. IF B1 (46,371) is less than C1 (240,000)
    = result will be B1 (46,371)

    Or if B1 (250,000) is greater than C1 (240,000)
    = result will be C1 (240,000)

    pls help me to assign formula.

    thanks & best regards

    faahem

    1. =IF(B1<C1,B1,C1)

      1. Hi, faahem

        Formula is =max(B1:C1) this will give the result which ever is of greater value.

  33. IF B1 is less than C1= result will be B1 Or if B1 is greater than C1= result will be C1

    pls help me to get the formula

    regards

    faahem

  34. Sub MyRange1All()

    Dim wSheet As Worksheet

    ' Amend ranges
    please help - why does the following only change one worksheet. I want to loop through all worksheets,

    ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range( _
    "A1:M1")

    For Each wSheet In Worksheets
    Next wSheet

    End Sub

  35. can any1 tell me a formula for this:
    Months: Jan Feb March Apr May
    Prodt1: 25 30 35 20 10
    Prodt2: 16 45 80 65 25
    Prodt3: 15 65 32 45 75

    i want to create a formula to catch the month having maximam rate in the next two columns.

    Thanks in advance.

    1. hi Abid
      your repor like below...
      Months: Jan Feb March Apr May
      Prodt1: 25 30 35 20 10
      Prodt2: 16 45 80 65 25
      Prodt3: 15 65 32 45 75

      how many "Prodt1" row is there that much you copy and paste in down row month also and use this formula =HLOOKUP(MAX(B3:F3),B3:F6,4,FALSE)
      below like...
      Months: Jan Feb March Apr May your result
      Prodt1: 25 30 35 20 10 March
      Prodt2: 16 45 80 65 25 March
      Prodt3: 15 65 32 45 75 May
      Jan Feb March Apr May
      Jan Feb March Apr May
      Jan Feb March Apr May

      1. Months: Jan Feb March Apr May "your result "
        Prodt1: 25 30 35 20 10 March
        Prodt2: 16 45 80 65 25 March
        Prodt3: 15 65 32 45 75 May
        Months: Jan Feb March Apr May
        Months: Jan Feb March Apr May
        Months: Jan Feb March Apr May

    2. Hi, faahem

      Formula is =max(B1:C1) this will give the result which ever is of greater value.

    3. Hi Abid,

      Sorry, I'm not sure I can follow you. To make things clearer, what exactly values do you want to have in the next 2 columns for Prodt1?

  36. Good morning,

    Could someone help me with a formula? I need to make the following logic.

    If A1&B1="Text" then Display "Text". If A1&B1 = Time entered then calculate Total Number of Hours worked i.e B1-A1

    Thank you very much in advance

    AQureshi

    1. If A1 and B1 are text values, do you want to display one of those texts, or both, or some other text?

  37. how i can calculate 50/100 times 45 = 23 in Microsoft excel

  38. Hi Svetlana

    If i have in cell (say A-1) Monday or Tuesday or Wednesday or Thursday or Friday or Saturday and i want a number to appear in A-2 if its finds on of those days. example A-1 equals "Tuesday" so A-2 fills with "100" how is this done?

  39. Hi Svetlana,
    I'm trying to find a formula like: =(if H2 - L2 > 5 "conflict" or H2-L2 < -5 "conflict"). Thank you very much in advance.

    1. Hi Emre,

      You can use a formula similar to this:

      =IF(OR(H2-L2>5, H2-L2<-5),"conflict", "")

  40. Need Help!
    If A1 says "Daniel" then B1 needs to be 30, but if it says "Jessica" it it needs to be 20, and if its any other name then the cell needs to be blank

    1. Hi Joe,

      Here you go:

      =IF(A1="Daniel", 30, IF(A1="Jessica", 20, ""))

  41. I want 10.3 is written 10 and 10.9 is also written 10.

    Garments 210 159
    in"1"Ctn 15 15
    Ctns 14 10.6

    I will packed 10 cartons with garments but not .6 carton. Plese tell me the formula which automatically write 10.6 to 10.

  42. Hi,

    What if I require A2 to show the value of A1 if less than 999 to be 0 (in A2 cell), greater than 1000 to be 15 (in A2 cell), greater than 2000 to be 50 (in A2 cell), greater than 5000 to be 100 (in A2 cell), greater than 10000 to be 200 (in A2 cell), greater than 20000 to be 400 (in A2 cell)?

    Is this possible?

    1. Hello Lee,

      You can do this by using the following nested If's:

      =IF(A1>20000,400,IF(A1>10000,200,IF(A1>5000,100,IF(A1>2000,50,IF(A1>1000,15,0)))))

  43. Hi Svetlana. Thanks for the guide, it has been very helpful.
    However, I'm in a bit of a tricky situation.

    Let's consider a data set of two columns (A and B) each with a 100 observations. I want to compare the same value from A with B (e.g. A2 vs B2) so that values of B that are more than 1.5 units greater than A is defined as TRUE. Here is an example: A2 = 0.5, B2 = 3.5. Since B is more than 1.5 units greater than A this would be defined as TRUE. The point is to show which observations that are changing significantly (which is defined as 1.5 units and more of A's values)

    I would think the mathematical expression for this would be something like: TURE if B = A + >1.5. Can't come up with a syntax for this expression that actually works. Please help!

    1. Hi Andreas,

      If my understanding of your task is correct, the following formula should work a treat:

      =IF(B1-A1>1.5, TRUE, "")

  44. Hi
    I need to make equation to convert percentage to points in excel Like that

    - From 60% to 70% = 2 points

    If the percentage between 60% & 70% the point will be displayed according to the percentage Like that

    1- IF the percentage less than 60% the point will equal 0 point

    2- IF the percentage = 60% the point will be equal 1.0 point

    3- IF the percentage = 65% the point will be equal 1.5 point, that means the is Variable not fixed

    4-IF the percentage = 68% the point will be equal 1.8 point

    Notes:

    - total range for the percentage is 10%
    - total point range is 2 Points

  45. Hi My question is if there would be alpha numeric value in particular cell then how can i use the if function see the example below :-

    60 DAYS DUE NET - NO

    45 DAYS DUE NET - Yes

    in above i want to use the if function if the days is less than 60 days it would be "Yes" else "No"

    1. Hi Gaurav,

      You can use use the LEFT function to extract the first 2 characters and NUMBERVALUE to convert them to a number:

      =IF(NUMBERVALUE(LEFT(A1,2))<60, "YES", "NO")

      1. sorry but formula given by you is not working

        1. On my test sheet, the formula works correctly for 1-digit and 2-digit numbers. For 3 and more digits it does not work. Is it the case? If so, please let me know the maximum number of digits you have before the "DAYS DUE NET" text.

          1. Thanks Svetlana ....formula after make changes as =IF(LEFT(A5,2)< "60","Yes","No")

  46. Very useful... Thanks a lot

  47. I need formula for slab 1-50 , 50-100 on ammount range

  48. Hello,

    I want to run formula for below please help.

    I want to calculate Over Time for my workmen, whose OT is above 30 minutes, if its = "30" it should represent acutal value of cell.

    How to apply formula for this?

  49. Good morning,

    Could someone help me with a formula? I need to make the following logic.

    If C60>L51, Use L51 value. If C60 <= L51, do C55xC59

    Thank you very much in advance
    Gustavo

    1. Hi Gustavo,

      Here you go:

      =IF(C60>L51, L51, C55*C59)

  50. Need help please.

    Two Columns of unique data, column A & B. New column (C) of data which is a sample of column A. I want a new column (D). Column D looks at data in column c & a. If they match, put value from column B (that's beside column A).

    C is less than A, so there will be no false answer.

    Thanks

    1. Hi Albert,

      Hopefully this is what you are looking for:

      =IF(C1=A1, B1, "")

      The formula returns a value from B1 if C1=A1, an empty string (blank cell) otherwise.

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