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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  26. Very useful... Thanks a lot

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

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

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

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

  31. I meant to put the IF statement as:
    =IF(B4="ISP",C3="Server: n/a",C3="Server:",IF(B4="ISP",E3="Server IP: n/a",E3="Server IP:",IF(B4="ISP",G2="Switch #: n/a",G2="Switch #:",IF(B4="ISP",G3="Router #: n/a",G3="Router #:"))))

  32. I'm working on an inventory sheet, where if I enter a specific word (ISP) into a cell it would change the words in multiple other cells. These other cells are pre-populated with default words but would be changed in the event "ISP" is entered into cell B4. Also I want to put the IF statement into a "stand off" cell, meaning a cell other than B4 or any of the other cells that will be changed, is that possible?
    Example:
    (formula is entered into say M2)
    =IF(B4="ISP",C3="Server: n/a",C3="Server:",
    =IF(B4="ISP",E3="Server IP: n/a",E3="Server IP:",
    =IF(B4="ISP",G2="Switch #: n/a",G2="Switch #:",
    =IF(B4="ISP",G3="Router #: n/a",G3="Router #:"))))

  33. hello

    can anyone help me with the follow?
    if A3=C1 then F1/2

    thank you

    1. Hello Petros,

      Here you go:
      =IF(A3=C1, F1/2, "")

  34. Hi - need help to have If statement - i.e if cell a1 has a value of #Value!, I want to add the cell content from Y1

    1. Hi Colin,

      Is my understanding correct that you want to add the content from Y1 to A1 when A1 has the #Value! error? If so, you can encslose the formula you currently have in A1 in the IFERROR function, like this:

      =IFERROR(your formula, Y1)

  35. Day's Sliver Gold
    Mon 34736 1453
    Tue 34736 1453
    Wed 31491 1453
    Thur 41606 1475
    Fri 36990 1473
    Sat 34736 1453

    I have a above data and I need a formula that when I select a day like mon then we get a result of that day silver and gold value in a row. Please advise for the same.

  36. Hi Abraham,

    Try creating a table with the value range you are looking for, for example create a table with the numbers 1 to 100 in the fist column and the second column with the result you are looking for. Then use the vlookup formula to populate the answer on the second table you are working on.
    This approach is a long term solution and my files I have used it for looking up service years in an organisation and based on the output create range band using pivot tables.
    If you send me the template with dummy data I will work it out with instructions to use the excel file.

    Regards,
    Ramki

  37. hi,

    I want to do an if function with something like this
    if(40<x<140,5%*5,).
    I tried it but it does not pick those numbers between 40 and 140 for the calculations. the output i get for those numbers are 0.

    please assist. thanks in advance.

    1. Hi Abraham,

      To pick numbers between 40 and 140, you need to embed an AND statement into your formula, for example:

      =IF(AND(A1>40, A1<140),5%*5,)

  38. Hello,

    I want to do a formula for working hours column E like if day column B is Sun or Ph, E=0 orelse E=column D (time out)-column C (time in).
    Please help.

  39. TABLE 1
    COUNTRIE CAPITAL RESULT
    INDIA LUCKNOW
    USA ITALY
    THAILAND BANGKOK
    THAILAND SPAIN
    INDIA NEW DELHI
    USA AMERICA

    TABLE 2
    COUNTRY CAPITAL
    INDIA NEW DELHI
    THAILAND BANGKOK
    USA AMERICA

    AS GIVEN IN TABLE 2, ARE THE CORRECT CAPITALS OF PROVIDED COUNTRIES AND ACCORDING TO THAT DATA, MATCH THOSE CAPITALS FROM TABLE 1. IF THE CAPITAL IS CORRECT, THEN RESULT SHOULD BE TRUE, OTHERWISE FALSE

    PLEASE HELP ME

    1. Hi Neeraj,

      I have used the data table structure you have mentioned in your post and got the required outcome you are looking for.
      Given below is the formula with the column reference:
      Table 1 with incorrect capitals - column A=Country, Column B=Capital and Column C="True/False".
      Table 1 with correct capitals - Column E=Country, Column F=Capital.
      Formula: =if(iferror(vlookup(A2, E:F,2,false)=A2,"TRUE"<FALSE".
      In the column you can get the True or False depending on whether the right capital has been typed in.
      Let me know is you get this or I can send you a sample template with your data.
      Regards,
      Ramki

      1. Oops, The table with the correct capitals should be Table 2 and not table 1.
        Regards,
        Ramki

  40. Hi Melarie,

    Create a LOOKUP table with the first column being 1, 2 and so forth. For each value give the corresponding text you desire in the adjacent column. Creating a table with any number of rows is a one time task and saves a lot of time and is not like creating long and complex formulas. In the database I assume that you have Column1 showing A1,A2 etc, Column 2 listing 1,2,3 etc [either manually typed or via dropdown list, Column 3 where you enter the formula "Iferror(Vlookup(value=A1,[range]table columnns 1:2,column2,false),0). The text you desire will automatically be picked up. I can send you a sample temple if you need one.
    Let me know is this worked for you.
    Regards, Ramki

  41. Pleas help me what formula should i have to use. If cell
    A1=1 the answer should D1, then
    A1=2 the answer should D2, then
    A1=3 the answer should D3, then
    A1=4 the answer should D4, and so on.

    hoping for you quick answer.

    Many thanks.

  42. Hi Svetlana,,

    Thanks for the solutions you've shared. I found them very helpful, though I am not that 100% sure that I can get them right. I haven't tried yet some of them, and to what my concern is, I didn't find a solution to my problem still despite of all the shared solutions. Could you please direct me to a certain solution to my case?

    My question was, how may I convert a given sample/answer (ex: 3days 10hours 35minutes) in a certain cell into a total minutes only (ex: 382719)?

    In other words I just want to simply convert them into total minutes using 1 formula with the given sample above as: 3days 10hours 35minutes

    Many thanks,

    Adzhar
    Reply

  43. if the cell has a vlue it has to take that value or else it has to take next cell value by multiplying *3.75
    Ex-if A1 has a vlue it has to take A1 or else it has to B1*3.75
    Anybody can help to solve this function

    1. Hello Hashid,

      Here you go:

      =IF(A1<>"", A1, B1*3.75)

      1. Thank you Svetlana ..Thanks alot it is very help to my day today work..once again thank you...

  44. I have one table that has a Zip code and other info about a person and also needs a County column filled in this same table. I have another table that has Zip Code with a County connected to it. How would I approach this?

    1. table 1 that needs the county info attached has the following columns.. Zip is H. Where I need the data is N. The other table where im pulling the county info from is.. Zip is column T and county column V

  45. Hello,

    I have an Excel spreadsheet where multiple people update frequently. I want column L to automatically update with the date when column J (status) was updated with any text information. Can I use If formula, and if so, how do I write it?

  46. Hi there,

    good day. I am trying to make a date to a number (the month to be number 1,2,or 3), but I don't know how to set the formular, could you please help?

    example:

    2/Jan/16 = 1
    3/Mar/16 = 3
    5/Apr/16 = 4

    Thank you very much in advance for your kind help. Looking forward to hear from you. have a great day.

    1. Hi Joyce,

      You can use the MONTH function for this, and the formula is as simple as =MONTH(A1) where A1 is a cell with the date.

      1. Hi Svetlana Cheusheva,

        Thank very much, wish you have a pleasant day :)

  47. Hi,

    I have a customer list in excel, and am trying to mark each customer as either 'new' or 'repeat'. A new customer is one that appears only once in the list, and a repeat customer appears in the list more than once.

    Can you help with this? Thank you so much.

    1. Hi Mick,

      You can use a formula similar to this, where column A is customer names:

      =IF(A1="", "", IF(COUNTIF(A:A, A1)=1, "new", "repeat"))

  48. Why is this not working?

    =if(G1="",E1,G1)

    However, when G1 is blank "", it is not giving me the value of E1, it is just showing a blank cell?

    When G1 contains a value, it gives me the value of G1

    Am I overthinking this?

    1. Hi!

      Your formula is all right, and you can make sure of this by testing it on a new sheet. Most likely there's some issue with your source data, but it's not possible to pin down the root of the problem without seeing it.

  49. hi,
    I have 4 excel sheets and work done in all sheets is of same kind, i work on particular numbers. so i want a formula by which i can know while working in any sheet that on this number you have already worked whether by coloring that number or highlighting or by any way. can anyone here hlp?

  50. Hi Svetlana,

    Good Day, I am working on two different cells, one cell has 4 categories(james,nadine,clark,leah) while the other cell has 3 options (yes, no, NA). Per category has different values, let say for james, the value of (yes, no, na = 20, 0, na), whilst, nadine has (10, 0, na). This is my formula but it doesn't seem to work:( I know there is too many conditions. I do not know how to simplify it. Thanks in advance and more power.

    =IF(C104="james",IF(D102="yes",10,IF(D102="no",0,IF(D102="NA",D102)))):IF(C104="nadine",IF(D102="yes",20,IF(D102="no",0,IF(D102="NA",D102))))

    1. Hello, Mitch,

      Could you clarify what result you need to get? If no is selected for James, what needs to be displayed in the resulting cell? Thank you.

      1. Mitch,

        Please try this formula:

        =IF(D102 = "NA", "na", IF(D102 = "no", 0, IF(C104 = "nadine", 10, IF(C104 = "james", 20, IF(C104 = "clark", 30, IF(C104 = "leah", 40))))))

        Please modify the values for clark and leah according to your data.

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