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

  1. Is there a way to convert the string "2015-08-26T14:22:27.306-04:00" to a readable date and time by creating a formula to ignore the T, and convert the date and time? It is not feasible to do this by hand as my data is in the hundreds, and grows everyday.

  2. Hi. I just wondering what is the formula to get Overtime Hours. The Normal hours is 8 and the Overtime Rate 1.5.
    Hope you can help me with this.

    Thank you.

    Louie

    1. I'm having problems trying to figure out the first name, last name, hours worked per day on a five-day workweek, with hours. worked 45, hourly wage $9.75, overtime hrs.5 at a time and a half, and the total earnings.please help me, I will be forever grateful.

  3. i have cell A1 with value 1.5.
    i want a value in cell A2. if value in cell A1 is less than 0.8, 0.8 should come in A2, but if value in Cell A1 is more than or equal to 0.8, same value should come in A2. like in my case 1.5.

    i tired this =IF(A1<0.8,"0.8","A1"), but its not working. i am getting text A1 in cell A2 not value 1.5

    please reply

    1. Hi Rahul,

      In Excel formulas, numbers and text references are not supposed to be enclosed in quotes. As soon as you remove them, your formula will work fine:
      =IF(A1<0.8, 0.8, A1)

  4. Dear Admin, I want to ask for help

    Here is my condition:
    - i have a table A to get the status "YES" for the first condition
    - i have a table B to search the value-text within, which is the name of the employees
    - and the third table C as a result
    I put this formulas at C that i wish to get 1.5 if "2 condition met" and 0 if "false"
    =IF(AND(H4="YES"),IF(ISNUMBER(SEARCH("name1",row1)),0.15,IF(ISNUMBER(SEARCH("name1",row2)),0.15,IF(ISNUMBER(SEARCH("name1",row3)),0.15,IF(ISNUMBER(SEARCH("name1",row4)),0.15,0)))),0)

    The problem is: when i add one more row (row5) it always give me "you've entered too many arguments for this function". Is there any other possible formula for me?

    Thank you very much

  5. Hi id like to create a formula using If condition wherein you have three ..
    For example

    I use =if(or(c27=40,c19*c26,c27=60,c20*c26,c27=80,c21*c26)) how can i checj this?it is always error

    1. Hi Grace,

      Use a nested If formula like this:
      =IF(C27=40, C19*C26, IF(C27=60, C20*C26, IF(C27=80, C21*C26, "")))

  6. Hi
    I want a formula to add several cells if they have a value say greater than £0.01. say cells B5 to B10 have a value greater than £0.01 and cells B11 to B13 do not have a value. so the count should be 6 and the cells that do not have a value turn red.

    Thank you.

  7. Hi
    I want a formula to add several cells if they have a value say greater than £0.01. say cells B5 to B10 have a value greater than £0.01 and cells B11 to B13 do not have a value. so the count should be 6.

    Thank you.

  8. i have a price list in sheet number 1 and an invoice in sheet number 2
    and i want to make an if function to help me when i write the code in the invoice the excel bring the price from the price list sheet.

  9. Thanks Svetlana, that works for my intent and purposes with a bit of mods. Now if you can help me with one more....
    I have 2 sheets containing about exact same data, but Sheet1 has several cells in Column B highlighted in Blue. How can I run a formula to color the matching cells on Sheet2 to be blue?

    1. Hi Jay,

      If you want to highlight cells on sheet2 that have the sames values in the same cells on sheet1 (regardless on cells' background color or other formatting), you can create a conditional formatting rule with the formula similar to this:
      =$B1=Sheet1!$B1

      For the detailed step-by-step instructions, please see:
      https://www.ablebits.com/office-addins-blog/excel-conditional-formatting-formulas/

      If you want to highlight cells on sheet2 corresponding to blue cells on sheet1, there is no formula for this, and the only way is writing a VB script.

  10. Hi guys, extremely helpful site. I have a simple one. I have a sheet with several names in say Column B. Column C is looking for the City. If Sam is found in Column B, return Toronto. If Joe is in Column B, return London. Sam, Joe and the other names occurs multiple times in Col B.

    Thanks

  11. It omits "Not Equal" '' signs in the formula :(

  12. Correction - =IF(D6"",D6/E6,"")

  13. Hi Svetlana, I need your help,
    I am displaying data in line graph but want to stop the line if there is zero instead of taking the line to '0' on X axis. There is a formula on the cell hence nothing is working, can you please help, have tried - 'Select Data -> Hidden and Empty Cells - > Gaps' but it does not help. Formula in the cell is

    =IF(D6"",D6/E6,"") and the cell displays blank without any value if D6 is blank yet it takes 0 in the graph.

    Thanks

  14. Please help if possible!
    Basically due to weekends (C Column is date included in metric sheet which i can change for data to be used within charts) some values in the F&G Column are 0 so it is returning #DIV/0!. I would like it if the values are 0 to put a "-" in. Is this possible?

    This is the formula i have at the moment.
    =IF((C3="Yes"),(F10/G10),"")

    1. Hi Ryan,

      Enclose your IF formula in the IFERROR function, like this:
      =IFERROR(IF(C3="Yes", F10/G10, ""), "-")

  15. Hello,
    guys please assist me here:
    column A1 to A100 has data i.e. 2, 3.5, 11, 25, 1, 90 etc

    In column B, I want to display numbers less than or equal to <=1.5.

    The formula must read data in column A.

    kind regards

    1. Hi Jonno,

      You can use the formula =IF(A1<=1.5, A1, "")

  16. Hi again.
    I'm going to send the attachment.
    Thank you

    Louie

  17. Hi Svetlana,
    I tried the IF function together with VLOOKUP and its still error. Can you please help me.
    im desperate with this.

    thanks.

    louie

  18. Hi. I just wondering, Im trying to get the tax rate tax and net pay using VLOOKUP but my always get me wrong (#NAME)
    If you could help me on this love. My head is like spinning trying to get the correct formula for tax rate.

    Thank you .

    Louie

  19. Hi Svetlana cheusheva,

    can I have your email ID. I WOULD LIKE TO SEND YOU MY EXCEL FILE ON THE COMPETENCIES THAT I HAVE MENTIONED EARLIER

  20. Hi Svetlana cheusheva,

    I have employee competencies for each position in worksheet and I want when I select the position in the other worksheet, I want all the competencies appear automatically. what is the formula please

  21. Hi Svetlana cheusheva,

    I need your help. I want to have a formula based on the appraisal rating. i.e AI IS 0 UNSATISFACTORY (no increment), A2 IS 1 TO 1.4 SATISFACTORY (increment from 1% to 3%), A3 IS 1.5 TO 2.4 GOOD (increment from 4% to 7%), A4 IS 2.5 TO 4.4 VERY GOOD (increment from 8% to 10%) AND A5 IS 4.5 TO 5 EXCELLENT (increment from 11% to 15%). My question is I want to have a formula in increment coloum which once I put the rating, automatically the increase amount % will show.

    for example an employee rated between 1 to 1.19, his increment will be 1%, if he rated 1.2 to 1.29, his increase will 2%, if he rated between 1.3 to 1.4%, his increase will be 3%

  22. Hi i want to change the Text with one excel sheet but i also want the text should change in other two sheet where the same date i have. but the other two sheet contain same data but there position is not same with the first one. for example I have a word " World" in column A and cell 1 but in other sheet i also have a word " World" in Column A but It's Cell in 8. Can you help me.

  23. please how do i create an IF function that denotes "1" when the response in a cell is "yes" and "0" when "No" is keyed in?

    thanks

    1. Hi Nonso,

      Here you are:

      =IF(A1="yes", 1, IF(A1="no", 0, ""))

  24. Hi Svetlana cheusheva....
    how to use if condition in my ques.......
    plz tell me......
    * display sales order after 2-jun,product name beginning with letter "G"and unit sold in excess 100.
    * display all details ; sales date on 1-jan or 3-jan and number of unit sold less then 150.
    * list those records sales date and 2-jan ; unit sold less then 150 and product name ending in letter "est".
    * display all records for countries in state of Florida with words north or south in country name and land area are more than 500.
    * display those records for countries in the state of California or Colorado with population between 200000 and 300000 and having unit of more than 100,000.

    plz tell my frnd svetlana.......

  25. who to convert 5421 to five thousands four hundred twenty one in excel

  26. Hi Svetlana cheusheva....
    how to use if condition in my ques.......
    plz tell me......
    * display sales order after 2-jun,product name beginning with letter "G"and unit sold in excess 100.
    * display all details ; sales date on 1-jan or 3-jan and number of unit sold less then 150.
    * list those records sales date and 2-jan ; unit sold less then 150 and product name ending in letter "est".
    * display all records for countries in state of Florida with words north or south in country name and land area are more than 500.
    * display those records for countries in the state of California or Colorado with population between 200000 and 300000 and having unit of more than 100,000.

    1. plz tell me frnd svetlana.....

  27. Hi!,

    I am trying to make a formula that will return the calculated value from another cell if a "check" boxes has a √ or even simple X in it, but return blank or 0 if left unchecked. I used =IF(B2="x",A1,0) where B2 is the bordered "checkbox" and A1 is the value from formula calculation in that cell.....

    What I get is "0" if ii put an x in the box and "-" if I leave it blank/unchecked?!

  28. Hi Svetlana cheusheva....
    plz giving to my ques. ans....
    * display sales order after 2-jun,product name beginning with letter "G"and unit sold in excess 100.
    * display all details ; sales date on 1-jan or 3-jan and number of unit sold less then 150.
    * list those records sales date and 2-jan ; unit sold less then 150 and product name ending in letter "est".
    * display all records for countries in state of Florida with words north or south in country name and land area are more than 500.
    * display those records for countries in the state of California or Colorado with population between 200000 and 300000 and having unit of more than 100,000.

    1. how to write in if condition..... my ques...

  29. Hi,

    I am looking for formula with multiple if conditions.

    some what like this;
    =if(J2="Chemicals","Heavy Industries->Chemicals"),if(J2="Medical Devices","Healthcare->Medical Devices)

    but this one does not work. and I have to apply same for another 7 conditions.

    Can any one help.

    1. Hi Sam,

      The correct syntax of nested IF's is as follows:

      =IF(J2="Chemicals","Heavy Industries->Chemicals", IF(J2="Medical Devices","Healthcare->Medical Devices", ""))

  30. Please can you help me?

    need to calculate if a cell (D58) has inbetween 6 and 12 in then it should equal F7 (which is £25.58).

    The cell before i need to know if the number was 5 or under so i =SUMIF(D58, "<=5",F6:F6) which is working fine.

    After i have figured out the 6 - 12 one i need to do the same for 13-18 and then one for 19 +

    1. Hi Laura,

      >if a cell (D58) has inbetween 6 and 12 in then it should equal F7 (which is £25.58).

      You can use the following formula:

      =IF(AND(D58>6, D58<12), F7, "")

      And for multiple conditions, you can use nested IF's:

      =IF(D58>19, F9, IF(D58>12, F8, IF(D58>6, F7, F6)))

      If D8 is 5 or under, return F6
      If D8 is between 6 and 12, return F7
      If D8 is between 13 and 18, return F8
      If D8 is 19 +, return F9

      1. Thanks

  31. Hi all,

    does anybody know if a formula exists that could have with the following scenario....

    if I have a cell with the text "19mm & 12.5mm" can I get another cell to display the same value which is shown in another cell.
    for example...
    I have a cell which is linking to a sheet and returns the calculation of "38" - I basically want that same figure (whatever the calculation is) to displayed in the box below it IF a certain cell displays the text "19mm & 12.5mm"

    1. Hi Daniel,

      Supposing that A1 is the cell with "19mm & 12.5mm", and B1 contains the result of the calculation you want to display (e.g. 38). Then you can use the following formula:

      =IF(A1="19mm & 12.5mm", B1, "")

      1. HI..
        I want to use if function with RAND() Function...

        I want to use =RAND()*7+$C$12 in cell C11
        if cell C12 is greator then zero...
        otherwise Result should be zero in cell C11

        help me..

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

          =IF(C12>0,RAND()*7+$C$12,"")

  32. Hi Svetlana, Hope your are doing great.
    Actually I have two columns and want to get the result in a different Workbook.
    Suppose Data is as follows:
    Month Velocity
    June 6.5
    July 8.0
    July 7.2
    August 8.8
    September 7.4
    I need to get the average of the 'Velocity' of the specific month.
    In the case above there are two instances of 'July' so when I get the value of July in the 'Month data' workbook, the cell should display the average of 8.0 & 7.2, in case there are three instances then it should consider those three values for average.
    Can this be done dynamically using some formula?
    Thank you

  33. * display sales order after 2-jun,product name beginning with letter "G"and unit sold in excess 100.
    * display all details ; sales date on 1-jan or 3-jan and number of unit sold less then 150.
    * list those records sales date and 2-jan ; unit sold less then 150 and product name ending in letter "est".
    * display all records for countries in state of Florida with words north or south in country name and land area are more than 500.
    * display those records for countries in the state of California or Colorado with population between 200000 and 300000 and having unit of more than 100,000.

    1. please giving answers to me....

  34. If B70 1600 then "Scania" or if value is 1000 then "Merc 1323" or if B70 is 450 then "merc 818" and so on.

    Please help

    1. Hi Shelly,

      Our blog engine often swallows the "<" and ">" symbols, sorry for that.

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

      =IF(B70<450, "merc 818", IF(B70<1000, "Merc 1323", IF(B70<1600, "Scania", "")))

  35. comment should read B70 less than 1600 it's not shown up the symbols for some reason

  36. Hi Svletlana, Please help me with the following formula,

    Im trying to get the cell to tell me which vehicle I will need based on the weight of the customers goods. total weight of customers goods is in cell B70.

    eg. If B701600 then "Scania" or if value is 1000 then "Merc 1323" or if B70 is 450 then "merc 818" and so on.

    Please help

  37. Need help with a formula. I keep getting an error. What I want to do is IF the value in I2=M and F2(numerical) < 8 then I would like the value to = Yes else No. The formula I thought I needed was

    =IF(I2="M" and F2 < 8, "Yes" , "No")

    But this doesn't seem to be working. Also can I compound these with something like:

    =IF(I2="M" and F2 < 8, "Yes" , "No") or (I2="S" and F2 < 3, "Yes" , "No")

  38. This post was really helpful. I thank you wholeheartedly.

  39. Hi Svetlana, Hope your are doing great.
    Actually I have two columns and want to get the result in a different Workbook.
    Suppose Data is as follows:
    Month Velocity
    June 6.5
    July 8.0
    July 7.2
    August 8.8
    September 7.4
    I need to get the average of the 'Velocity' of the specific month.
    In the case above there are two instances of 'July' so when I get the value of July in the 'Month data' workbook, the cell should display the average of 8.0 & 7.2, in case there are three instances then it should consider those three values for average.
    Can this be done dynamically using some formula?
    Thank you

  40. please me in constructing the formula...example i have here grade of %Ni and %Fe and i want to determine it directly where does the % falls in example for %Ni=1.26 and %Fe=25.79
    OV1 15<44
    OV2 =45<46
    L1 =48
    L2 =46 =1 =25
    S1 >=1 <1.5 1.5 =2
    BR <1 <15

  41. I need H5 to be multiplied by 6% if > A1 and multiplied by 7% if > than A2 and multiplied by 8% if > A3.

    1. Hi Kristal,

      Here you go:
      =IF($H5>$A$1, $H5*6%, IF($H5>$A$2, $H5*7%, IF($H5>$A$3, $H5*8%, "")))

  42. thanks! - sent you the info via email

    1. The problem was with percentages entered as text strings. Emailed you back the fixed sheet.

      1. Thanks so much for the help! appreciated!

        Now i have a question around "if i can't get the text to percentage on the sheet to work unless i double click the box and click on the accept icon" (tick box image).

        Is there a way to change format quicker on the sheet.

        I've tried selecting the column, going to number format and changing to percentage - but then i still have to click in each box to accept it, before the formula works. Trying to see if i can save myself time and do it with a shortcut.

        Thanks

        1. In the worksheet you sent to us, I fixed the percentages in the following way:

          - Select column H (the Percentage column), press Ctrl+H and replace % with nothing (leave the "Replace with" box empty and click the Replace all button).

          - In some empty column in row 2, enter the formula =H2/100, copy the formula down to other cells, copy the column with the formula, then select column H, right click and select Paste Special > Values. The result would be decimal numbers like 0.75.

          - Apply the Percentage format to column H.

          Done!

          1. It was and great thank you - it fixed it perfectly!!

  43. Hi Svetlana

    Thanks but unfortunately that doesn't work either, tried it and even if i have a 10% on the probability - it still brings up the number.

    1. Hmm... this is very strange. The formula works just fine for me. If you can send us a sample workbook, and we will try to figure this thing out.

  44. Hi

    I'm trying to get a formula to work this is the detail:

    Column G = sales
    Column H = probability
    Column J = status

    I'd like to get a formula to work if its status is open and is above 75% then it returns the sales number - i have this but it won't work
    =IF(AND(J300="Open",H300 >75),G300,"")

    1. Hi Ash,

      Your formula is correct except that you omitted the percentage :)

      =IF(AND(J300="Open",H300>75%),G300,"")

      If you'd rather not use the percentage char in formulas, then it should read H3>0.75.

  45. So I entered the formula to have a cell name itself the workbook name which is a date. The other cell that I have turns into the day of the date. But since I have done = it only reflects the date not the day.

    1. Hi Justin,

      Sorry, I am not sure I can follow you. If the problem is just with displaying the date rather than the day of the week, select the cell, press Ctrl+1 to open the Format Cells dialog and select the desired date format there.You can find the detailed steps and lots of examples in our Excel Dates tutorial:
      https://www.ablebits.com/office-addins-blog/change-date-format-excel/#custom-date-format

      If you have a different issue, please clarify.

  46. If we have two different worksheets.For example Workbook1 contains weights 0.5,1,2,3 and other worksheek contains the master that means that fine contains 0.5 value 10.00,1 value 20.00,2 value 30.00 and 3 value 40.00.

    And i want to use formula to upload the same figure in Work sheet 1 also as a value that means if the weight is 0.5 that value should be 10 like that how to make formula

  47. HI there,

    can you help me with this project?

    IF (A2 >26, A242, A263, A284,A2<104),4 "")

    I appreciate your kind help

    1. (A2 >26, A2>41, A2>42, A2>62,A284,A2<104),4 "")

      1. Hi Fahad,

        Sorry, I cannot understand the conditions. Can you elaborate please?

  48. Helooo,

    how can utilize this formula in my office reminders.

    I have certain daily task that is fixed in every month. let me know how can I create reminders, that today I have particular task to perform?

  49. A1= Level 33
    B1>50%=YES and B150%=YES and C1<50%=NO

    1. I am not sure I fully understand the logic. Nevertheless, here's the formula as per your conditions:

      =IF(B1>50%, "YES", IF(C1<50%, "NO", ""))

  50. hi there,
    Searching for help,
    I wanted my data to produce end result YES or NO:
    must meet condition as below:

    A1= Level 33
    B1>50% = YES and B150% = YES and C1<50%= NO

    please help , thanks!

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