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 15. Total comments: 4823

  1. Hi! I could use some help if anyone is available.

    I have 2 sheets that contain the same column called "Content Title".

    Sheet 2 has an additional column with data in it called "Total Unique Users". I want to bring over the data from Sheet 2 column "Total Unique Users" to Sheet 1 if I can find the same Content Title in Sheet 1.

    For example, If Content Title in Sheet 1 is equal in Sheet 2, pull the data from the "Total Unique Users" column in Sheet 2 into Sheet 1.

    Any help is appreciated. Thank you!

  2. I have 2 columns of numbers , cOL C&D . I need Col A to represent a letter based on these criteria.
    If C is greater than D then show text H else show A

    I have =IF($C$3>$D$3,"H","A") this works OK but if the numbers match I need to show text D. How can I do this please..

      1. Thanks so much for your FAST solution - it works great.. in fact you are 'Alexander the great'.

  3. Hi,
    I'm trying to use formula in a budget where
    C3 D3 ($eg) E3(monthly)
    yearly $95000 = D3/12
    monthly $500 = D3*1
    weekly $50 = D3*4

    Please assist with e3 cell formulas

    Regards
    Annette

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

      =IF(C3="yearly",D3/12,IF(C3="monthly",D3,IF(C3="weekly",D3*4,"")))

  4. I want to write a statement in sheet named Master, that reads a cell in sheet named 2021 and if it says N, come back with NO. If it is blank, I want it to come back with a blank. If it is anything else, I want it to give me the value in another cell in sheet 2021. How do I do this? I have tried a bunch of different IF functions and everything comes back with an error.

  5. To everyone, I need help.
    Column A1: John Doe
    Column A2: Jim Doe
    Column A3: James Doe
    ...

    So, columns B should be:
    Column B1: 12345
    Column B2: 23456
    Column B3: 34567

    John is 12345, Jim is 23456, James is 34567.
    How to make formula that puts their numbers when I put their names?

  6. Working on setting up a asset inventory sheet using existing bar codes,

    I can get the Barcode to scan insert Barcode number and insert scan date. But I also need it to search the spreadsheet for a matching barcode, and update the scanned date with the current date.

    Present code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim x As Integer
    For x = 2 To 1000
    If Cells(x, 1).Value "" And Cells(x, 2).Value = "" Then
    Cells(x, 2).Value = Date & " " & Time

    Cells(x, 2).NumberFormat = "m/d/yyyy h:mm AM/PM"

    End If

    Next

    Range("B:B").EntireColumn.AutoFit
    End Sub

    Would like to have it to where I scan in one Cell and have it search for exsisting data match or append @ the end of the rows.

  7. =(IF(N191.4,N191.7,N192.4,"NORA"))))
    Hello!
    I would like to write a formula saying:

    if N191.4 and N191.7 and N192.4 write NORA

  8. =IF(N191.4,N19<1.7, "PA"))
    Hello, This formula enters False or True instead of PA when the value is between 1.4 and 1.7.
    Thank you for your help

  9. I have spent hours and cannot figure this out. I have a spreadsheet with contract numbers and material numbers, a second tab has the same information contract numbers and material numbers but it includes a line for each shipment. I am trying to come up with a formula that counts the number of shipments, So anything greater than 0 that matches the contract number and the material number count as 1. I cannot figure it out: =COUNifs('Aug 2021'!E:E,">0",'Aug 2021'!J:J,D2,'Aug 2021'!I:I,E2) This is the closest I have gotten and it comes up with the #name?

  10. I don't understand why my if statement does not work. I am searching for age based on year in 2 digit format. 98, 02, 13 ect. The year for the exercise is 2014. The formula I wrote follows:

    =IF(F6<14, 14-F6, 114-F6)

    The results all come back 14-F6 no matter if the value is above or below 14. but if it is above 14 shouldn't the function follow the false result function of 114-F6?

    Does a have to be equated to zero specifically or something. I finally got the function to work with =IF(F6-14>0, 100-F6+14, 14-F6) but that seems like a lot of extra steps compared to my first equation.

    1. Hello!
      I’m sorry but your task is not entirely clear to me.
      What are the values recorded in F6? Are these values written as number, date, or text? The value 02 is text and cannot be compared to a number. Specify your question.

  11. Hello, I'm wondering if you can help me? Looking to create a formula to simply identify currency 'EUR' or 'USD' in source column, to then compute exchange rate for that currency in next column. I have been trying to use the 'IF' function, but it doesn't work. For example:

    Column A: 'EUR' or 'USD'
    Column B: =IF(A1=EUR,"4.50","3.67")

    However this is giving me #NAME? error.

    Was wondering if you had any suggestions?
    Thanks!

  12. I have one column where hours will be put. If one day has zero hours, I want another column on same day to put DYO, and in a third column for it to put day off, and all other columns to remain blank. This will all remain on one date or line. I would like it all done based on that one column having zero. Any ideas on formula?

  13. Hello, I have this formula that works individually but will like to have it as a single formula.
    =IF(L6="SUPPRESSED", (EDATE(N6,11).
    =IF(L6="UNSUPPRESSED", (EDATE(N6,3).
    In my table, the L column returned "Suppressed" if the value connected to its formula is 1000. So I want a single formula the will return (EDATE(N6,11) and (EDATE(N6,3) if the L column returned "Suppressed" or "Unsuppressed".

  14. Hi everyone,

    Please could someone help me I am trying to create the following

    If M2 is less or equal to 0-0.99 return the text in cell N2 "0"
    If M2 is less or equal to 1.00-1.99 return the text in cell N2 "1"
    If M2 is less or equal to 2.00-2.99 return the text in cell N2 "2"
    If M2 is less or equal to 3.00-3.99 return the text in cell N2 "3"
    If M2 is less or equal to 4.00-4.99 return the text in cell N2 "4"
    If M2 is less or equal to 5.00-5.99 return the text in cell N2 "5"
    If M2 is less or equal to 6.00-6.99 return the text in cell N2 "6"
    If M2 is less or equal to 7.00-7.99 return the text in cell N2 "7"
    If M2 is less or equal to 8.00-8.99 return the text in cell N2 "8"
    If M2 is less or equal to 9.00-9.49 return the text in cell N2 "9"
    If M2 is less or equal to 9.50-9.99 return the text in cell N2 "10B"
    If M2 is equal to 10.00 return the text in cell N2 "10A"

    Any help would be hugely appreciated.

    1. Hello!
      The formula below will do the trick for you:

      =IF(INT(M2)<9,INT(M2),IF(ROUND(M2,2)<9.5,9,IF(ROUND(M2,2)<10,"10B","10A")))

      You can learn more about rounding in Excel in this article on our blog.

      1. Thank you Alex!

  15. Trans. Date Type of Customers Due Date

    06/10/21 Regular 06/25/21
    06/10/21 Consignment 06/17/21

    Note:

    1) What is the formula to add 15 days from the date of transaction

  16. Good

  17. Hi. I am trying to create a formula that compares a single cell to an entire column(unlimited number) of data. Basically I have a tracking # in a cell and need to compare that to a column consisting of tracking #'s that have been shipped(I will be continuously adding to this column). I want to create a column that lets me know if that tracking # in a cell has been shipped.
    So I was tried using formula:
    =if(C9=I:I,"Shipped","Freezer")

    But it doesn't not work. even though that cell(C9) matches a number in I:I, it will not display shipped and only displays freezer instead.

    1. Hello!
      The IF function does not work with ranges. Please use the following formula

      =IF(ISNUMBER(MATCH(C9,I:I,0)),"Shipped","Freezer")

      You can learn more about MATCH function in Excel in this article on our blog.

  18. I am trying to get the the IF function for this problem, I need to give each person a raise based on their yearly salary (column M) and team (Column G): Green Team 5%, the Red Team 7% and the Blue team 3.5%

    =If(G2="Green",M2*.50,IF(G2="Red",M2*70),IF(G2="Blue",M2*.35)))

    I don't know if its correct, but only on green condition displayed correctly. I am new to this, can you help me.

    1. Hello!
      Please try the following formula:

      =IF(G2="Green",M2*0.5,IF(G2="Red",M2*70,IF(G2="Blue",M2*0.35,"")))

      Hope this is what you need.

      1. Hi! I tried using the formula you've gave but the Red isn't appearing.

  19. Hi,

    I am trying to make a ledger and there for using the formula
    =+IF(D16-G16>0,"Balance is"=D16-G16,""NIL"")
    What i am trying to do is that if the answer to the query is positive then i want the outcome to be as "Balance is___" else "NIL"
    However there is some error in the formula that i am not able to know

    1. Hello!
      Please try the following formula:

      =IF(D16-G16>0,"Balance is "&(D16-G16),"NIL")

      Hope this is what you need.

  20. How to get DateValue to work text in following format "Wednesday, July 7, 2021 11:09 AM" inside string ?

    1. Hello!
      You can convert text to date using the formula

      =--MID(A11,SEARCH(",",A1,1)+2,100)

      We have a tool that can solve your task in a couple of clicks - Text to Date tool.
      It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.

  21. i cannot do the addition and subtraction in one cell in Total.
    like - if c3>1 add and if c3<1 than it is 0

  22. I'm trying to use a logic function to get standard pricing calculation from one worksheet to another. I thought this would be done through =if(A2:A22 = !sheet1$A$2:$A$22, c2:C22). What am I thinking incorrectly on the logic side?

  23. Hi,

    Im trying to set up the following:
    =IF(FOTB!A3="PID: Sync Identity to network"; "=FOTB!C3"; "0")

    So I'm trying to accomplish that:
    When A3 on sheet FOTB equals the text PID: Sync Identity to network
    the value from cell C3 should get copied to the cell i'm pasting this formula in.

    The issue here is that excel just shows =FOTB!C3 instead of the value of the cell.

    How can I fix this?

    kind regards,

    Glenn

    1. Hello!
      Use something like this

      =IF(A3="PID: Sync Identity to network"; C3; 0)

      This should solve your task.

  24. I am trying to write a formula that if A1=number AND F1>=different number, then A1 turns red. I'm trying to track mileage of my fleet and when they are due for oil changes. A1 is the unit # and F1 is the current mileage. If F1 is greater than or equal to the oil change needed mileage, then A1 would turn red.

    Thanks.

  25. how do we add an extra number to an formula that already has a existing formula. And how do we add a common number to a series of cell having different formula

  26. Hi! I need your help. What I want to happen is every letter that i enter should the next cell must present a number. for example
    W=1
    H= 2
    I= 3
    T= 4
    E= 5

    But not just one letter.. If I want to type "WH" the next cell should present "12" since W=1 and H=2 or if I want to type "WHI" next cell should display "123". and if it is shuffled like "HIW" it should display as "231".

    Thank you very much

  27. Thank you for the info. Is it possible to put in the If function a range of cells ?
    On a column (A) I have a list of emails that I need to classify. In Column B I was hoping to have the valid emails displayed and on column C the invalid emails. I have the list of valid emails on another sheet (Valid emails).
    The way I wanted it to work is: if an email in column A is on the 'valid email sheet', then it should display said email on column B, if not, display "no". I started with the following formula but it only works for the one email.
    (in cell B2) => IF(B2='Valid email'!$A$2:$A$70;B2;"no") (range of emails in valid sheet is from A2 to A70)
    My problem is when I copy it down to the rest of the column it does not work and all values are "no".
    What should I add to the formula so it looks for the value in the other sheet and displays said email or displays no?
    Thank you very much!

    1. Hello!
      Please try the following formula:

      =IF(ISNUMBER(MATCH(B2,$A$2:$A$70,0)),B2,"No")

      I hope this will help, otherwise please do not hesitate to contact me anytime.

  28. Hi, I'm trying to combine two functions, I have a requirement to contact customers every 6 months before they begin receiving our services and once a year after. I'm trying to get the function to identify the last date contacted, then based on if there is a Yes or No in column B2 return a Next Contact date either 6 months or 12 months in the future. This is the formula I'm working with but I can't seem to make it work... Any thoughts?
    =IF(B2='Yes',[EDATE(A2,S2)],[EDATE(A2,S3)])

    (S2 refers to the 6 months and S3 refers to the 12 they are just single cells with a 6 or 12.)

    Thanks!

    1. Hello!
      I have not been able to verify your formula. It doesn't work for me. This formula will return TRUE if the date in column A is the most recent.

      =A1=MAX($A$1:$A$100)

      You can copy this formula down along the column.
      For me to be able to help you better, please specify which formula you mean and describe the problem in more detail.

      1. I'm not looking for it to return anything. I'm looking for it to find a different solution based on what the column says, for example if the Date in A is 1/1/2020, if column B says YES I want it to Return A2+6months = 7/1/2020 in Column C and if column B says NO I want it to return 1/1/2020+12 months = 1/1/2021 in column C Then I'm going to set up conditional formatting to highlight the column based on the time out from the Column C information but that part of the spreadsheet is working well.

  29. ( A )
    (ROW 1) TIME IN 24:00
    (ROW 2) TIME OUT 8:00
    (ROW 3) HOURS WORKED 8:00
    I have row 1 and 2 formatted as [h]:mm and the following formula in Row 3:
    =IF(A2>A1,A2-A1,1-A1+A2)
    What I need is for the formula to return blank or 0 if no times are listed in Row 1 or 2, right now it returns 24 if cells are empty.

    Any assistance would be greatly appreciated, thank you

    1. Hello!
      If I got you right, the formula below will help you with your task:

      =IF(OR(ISBLANK(A1),ISBLANK(A2)),"",IF(A2>A1,A2-A1,1-A1+A2))

      You can learn more about ISBLANK function in Excel in this article on our blog.

      1. It worked, thank you so much, I was missing the "ISBLANK" for A2, much appreciated.

  30. Hi, I am impressed that someone is actively replying to comments. plz help, all I wanna know is a function for this sort of rule. If A:A has a text of "name", B:B should be on E1, then E1 will add all value from B that has "name" on it. idk if thats clear but im no expert. help

    1. Hello!
      Sorry, I do not fully understand the task.
      I recommend paying attention to the SUMIF function.
      If this is not what you wanted, please describe the problem in more detail.

  31. hello alexander i need you help

    formula for fresh eggs order

    given:

    guest count = 3515 heads
    days = 1
    daily consumption of eggs per guest = 1.46 pcs
    eggs left before ordering = 300 pcs

    How many eggs i have to order given below using a formula in excel?
    Consider also that i still have 300 eggs left, see above

    guest = 751 heads
    days = 15
    daily consumption of eggs per guest = 1.46 pcs

    Thanks

  32. hi good people i am hoping to get a help from you all .... i want to pull out all the data with the same name in a new cell how can i used or what conditional if function to use please help thank you

  33. What's the syntax for the following?

    If A1=Yes, then display value from Column L , Column B.

  34. This is very useful website. This article is really helpful. Thank you so much for sharing this great knowledge

  35. I want to select out a subset from a list(rows) of purchases- columns have date price, article, buyer etc.
    I can make a column with "yes" or "No" which defines the rows I want, but now how do I select the whole row and copy onto new chart, or hide the rest?

    1. Hello!
      To get a list of rows conditionally, I recommend using the FILTER function. You can get detailed instructions in this guide.
      I hope I answered your question. If something is still unclear, please feel free to ask.

  36. Hi,
    Could you guys please help me to clear this below issues.

    Cell A1 "APPROVED"
    Cell A2 "APPROVED"
    Cell A3 "APPROVED"

    If(Cell A1:A3="APPROVED", Cell A4="APPROVED", "NOT APPROVED").

    How i can solve this issue.

    1. Hi,
      I believe the following formula will help you solve your task:

      =IF(SUM(--(B1:B3="APPROVED"))=3,"APPROVED","NOT APPROVED")

  37. Hi I really hope I can explain myself well. So basically, if a column contains a 'No' entry, then most of the columns that come after will have an 'N/A' entry. I'm trying to automate this but what I'm struggling to do is if the condition is false, then I don't want anything to happen to the cell (whatever entry in the cell should remain). For instance, If it's a 'No' then I want 'N/A' but if it's a 'Yes' then I'll have to put a date. But what happens is that when I create the formula for the first cell and tries to drag, it changes all my dates to blank which is not what I want. I want the dates to remain.

    Any help would be greatly appreciated, thanks

    1. Hello!
      Sorry, you didn't write your formula. So I am assuming you are using relative cell references. They change when copied. Use absolute cell references.
      If this is not what you wanted, please describe the problem in more detail.

  38. Hi,
    If I select name from dropdown list in cell A1, automatically name of country of the person should display in A2 and his identification number should display in A3.
    Please help me for setting this formula in excel.

  39. I want to use the if function to populate a cell with 1 of 3 possible values. I have a start time and a finish time which gives a total time worked. I want to take the total time worked and if it is less than 5:30 hours worked then 0:00 break, 5:30 hours to 7 hours is 0:30 break and over 7 hours is 1 hour break. Help would be appreciated.

    1. Hello!
      If I got you right, the formula below will help you with your task:

      =IF(TIME(7,0,0)>B1,TIME(1,0,0),IF(TIME(5,30,0)>B1,TIME(0,30,0),0))

  40. Hello,

    I was wondering if anyone could help me - I am stuck with figuring out a formula to calculate a commission sheet with percentage according to a job role.
    example:
    Person A - gets a commission value in cellA1 and B1 added together however Person B only gets 10% of value in Cell A.

    Can anyone help me figure this formula out? - I tried to make it sound a little like:
    If cell J5="Y" then cell J6 = A1+B1 or if cell J5="N" then J6=10%ofCellA1

  41. I need help with the following

    cell E14 has check box
    cell I14 has check box

    cell E4 has data
    cell F4 has data

    cell F14 is the cell I need filed with the correct data

    What I am trying to accomplish
    if cell E14=true and cell I14=true then fill cell F14 with data from cell E4
    if cell E14=true and cell I14=false then fill cell F14 with data from cell F4

    thanks for your time
    Jason

  42. Im trying to have a column in excel that uses 2 equations based off of a word that is placed in another column .

    for example if J5 says Suburban i want the equation in N5 to be M5*9/100 and show the answer to the equation but if J5 doesn't say this and says Mercedes i want the equation to be M5*11/100 and show the answer.

    Also how do you copy to function down the column so it is using the right line number.

    I thought that I had it but its not giving me the totals

    Thank you!

  43. Thank you so much it is working now

  44. In the above formula "OP" condtion is working fine...But in the "IP" when i enter in the cell 4 ,then it is showing "OUTSIDE".

    As per my condition for "IP" G25 then "OUTSIDE"

    Please support to solve this

  45. Thank you so much...i will check

    If Cell G2 contain text ,then how we can solve

      1. This is working fine

  46. And with this i also need to add one more condition....if G2 cell not cotain number then will show "blank"

      1. In this formula "OP" condtion is working fine...But in "IP" when i enter 4 ,it is showing "OUTSIDE".

        As per my codtion it should only when i enter 5

        1. Please help how to solve thiscalculation...In "IP" G25 then "OUTSIDE".

  47. Kindly help to combine below formula together...Actually i need to put below formula in one cell

    =IF(AND(K2="OP",G2<4),"WITHIN TIME","OUTSIDE")
    =IF(AND(K2="IP",G2<5),"WITHIN TIME","OUTSIDE")

  48. Hello,

    I have to IF/Then statement of

    =IF(DH53=DI53,"matches", "doesn't match")

    Cell DH53 = 0.00 and DI= 0.00

    For some reason it's returning a Doesn't Match result but it does match. I have multiple that return back the Matches results but a few that return back the doesn't match result even though the two cells do match. Am I doing something wrong? I've tried reformatting all the cells so they are all the same format but nothing seems to change. Why would the IF/Then statement return back a false result if it is in fact true

    Thanks so much for your help!

    1. Hello!
      Unfortunately, without seeing your data it is difficult to give you any advice. 1. Perhaps one of the values is written as text. 2. If these values are calculated by formulas, then they may differ in decimal places. For example, 0.0002 and 0.000008. In the cell, you will see 0.00. I recommend using the ROUND function in this case.

  49. I have a problem please help I'm very new to this, sorry.
    I want to show the result only if the full operation is done for example.
    K15 =C15*E15+F15 otherwise 0

  50. Hi!

    I'm looking for some help in using an IF statement to perform a math operation, I can’t seem to get it right:

    I have:
    Column A: Firm (either A, B, C, D or E)
    Column B: Measure (either sales, price, or promotional price)
    Column C: Product (a lot, but coded as numbers)
    Column D-FB: Value of measure per week (155 weeks in total)

    I want a cell to return: ((sales 1 * price 1) + (sales 2 * price 2)) / (sales 1 + sales 2)

    Where:
    Sales 1: sales of firm A for product 1
    Price 1: price of product 1 of firm A
    Sales 2: sales of firm A for product 2
    Price 2: price of product 2 of firm A

    Thus, firm is always A, but measure and product differ. Then, I would autofill the cell to the right (from column D to FB to create a new row). I would like to do the same for promotional price.

    I hope I explained it well enough and any help would be much appreciated! Thank you!

      1. Thank you for your quick reply!

        For example:

        A1: Firm (header)
        A2: A
        A3: A
        A4: A
        A5: A

        B1: Measure (header)
        B2: Sales
        B3: Sales
        B4: Price
        B5: Price

        C1: Product (header)
        C2: 1
        C3: 1
        C4: 2
        C5: 2

        D1: Week 1 (header)
        D2: 1,670
        D3: 9,813
        D4: 1.42
        D5: 1.83

        E1: Week 2 (header)
        F1: Week 3 (header)
        etc.

        =IF((D2+D3);((D2*D4)+(D3*D5))/(D2+D3);0) results in 1.77

        This 1.77 is then the new combined price of product 1 and 2 for firm A for week 1.

        In this example, I’ve already filtered on the right firm, measure, and product, but I would like to make a function where I would only have to type in the firm and product and not manually select them as I’m doing now. So for D2 * D4 for example, only multiply cells if one cell is sales of product 1 for firm A and the other is price of product 1 for firm A.

        I hope this makes sense, thank you in advance!

        1. Hello!
          I’m not sure I got you right. If your criteria are firm, measure, and product, then you can find the desired cell in column D using the INDEX + MATCH function, as described in the article "Excel INDEX MATCH with multiple criteria".
          The criteria for cell D2 are "A", "Sales", 1. For D4, "A", "Price", 1. And so on.
          I hope it’ll be helpful.

          1. Yes, I've managed to create the formula with the use of index and match! Thank you very much for your help!

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