Excel IF Statement Explained

Excel_IF_Statement_1

Watch the video extract as seen on YouTube, then read the full tutorial below.

Click the Full Screen button on the player to watch it in HD.

Excel IF Function Explained

In this Microsoft Office Online Training tutorial we’re going to explain how to use the IF function (also known as IF Statement), and look at a couple of different applications for it.

With the IF statement you can tell Excel to perform different calculations depending on whether the answer to your question is true of false.

The function wizard in Excel describes the IF function as:

=IF(logical_test,value_if_true,value_if_false)

But let’s translate it into English and apply it to an example:

In the table below we want to calculate a commission in column G for each Builder based on the number of units in column D.

Excel-IF-Statements-Explained

We’ll say that for units over 5 we’ll pay 10% commission based on the Total $k figure in column F, and for units of 5 and under we’ll pay 5% commission.

Our IF statement for row 2 would read like this:

=IF(The number of units in cell D2 is >5,Then take the Total $k in cell F2 x 10%, but if it’s not > 5 then take the Total $k in cell F2 x 5%)

The actual formula we would enter into Cell G2 would be:

=IF(D2>5,F2*10%,F2*5%)

Remember; as the number of units in row 5 is not greater than 5 the formula would calculate a 5% commission.

Other applications of the Excel IF Function

We don’t have to use the IF function to perform a calculation.  We could use it to return a comment.   If we take the previous example again, we could have asked Excel to put a note in the cell like ‘Pay 5%’ or ‘Pay 10%’.  To do this our IF formula would look like this:

=IF(D2>5,"Pay 10%","Pay 5%")

Notice the difference between the two formulas are the inverted commas () surrounding the results we want Excel to produce.  These inverted commas tell Excel that the information between them is to be entered as text.

Below is a screen shot of how the formula looks in the Formula Bar and the result returned in column G.

Excel-IF-Statements-Explained

Try other operators in your IF function

Because the IF formula is based on logic, you can employ tests other than the greater than (>) operator used in the example above.

Other operators you could use are:

  • =             Equal to
  • <             Less Than
  • <=           Less than or equal to
  • >=           Greater than or equal to (if we’d used this operator in our above example row 5 which had 5 units would have returned Pay 10%)
  • <>           Less than or greater than

Now practice. Copy and paste the formulas used in these examples into your workbooks to practice, or download the spreadsheet used in the example above.

Want More Excel Formulas

Why not visit our list of Excel formulas. You’ll find a huge range all explained in plain English, plus PivotTables and other Excel tools and tricks. Enjoy :)

Plus sign up for our newsletter below and receive weekly tips & tricks to your inbox, plus you’ll get our 100 Excel Tips & Tricks e-book free.

Did you find this useful, or did it just confuse you?  Let us have your comments below.

FREE PDF Download
100 Excel Tips & Tricks

Excel Tips & Tricks E-Book
Just enter your details below
* indicates required

We respect your email privacy

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *

Comments

  1. raymark says

    Hi mynda

    Can you please help me understand this kind of formula.

    =IF(IF(IF(IF(CONCATENATE(IF(AND(E12=”-”,C12=”-”),””,IF(AND(E12>0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)0,C12=”-”),”PTA with no or not within Time entries in TKG”,IFERROR(IF((E12-C12)<-(1/1440),"PTA with no or not within Time entries in TKG",IF((D12-F12)<0,"PTA with no or not within Time entries in TKG","")),""))),"/",IF(C12="-",IF(E12="-","","Missing LAN"),""),IF(E12="-",IF(C12="-","","Missing PTA"),""))))))

    • Catalin Bombea says

      Hi,
      To understand a formula like this, which is just a comparison between a set of values and a set of conditions, you need to understand that specific data requirements and the meaning of every calculation like D12-F12. Those conditions and rules are known only by the one who created that formula, we have no idea of what the requirements are.
      Regards,
      Catalin

  2. zulfiqar says

    In if function I chosen some part of the text for logical test which is not accepted by Excel
    Exampl

    • Mynda Treacy says

      Hi Zulfiqar,

      Sorry to hear you’re having trouble with an IF Function. If you can give me an example I might be able to help.

      Mynda

  3. Jerry Roth says

    I have 5 cells (C5, C6, C7, C8, C9) that are being populated with numbers driven by if statements. I am now trying to sum all the colums utilizing the =sum(C5:C9) formula. The columns are populate with 4, 6, 2, 0 and 5 respectively and they are formated as a number. I would expect the result to be 17 but it is returning 0 as the result. What am i doing wrong?

    • Mynda Treacy says

      Hi Jerry,

      It sounds like the values that the IF function is returning are actaully text as opposed to numbers.

      If the numbers in your value_if_true and value_if_false arguments are in double quotes then Excel is returning text. e.g.

      =IF(A1>0,"5","1")
       would return numbers that are actually text whereas:
      
      
      =IF(A1>0,5,1)
       would return numbers.
      
      I hope that helps. If you're still having problems please send me the workbook via the help desk so I can see what you're working with.
      
      Kind regards,
      
      Mynda.
  4. Gireesh says

    =IF(F23=19300,20,IF(F23>18500,19+(F23-18500)/800,IF(F23>17200,18+((F23-17200)/1300),IF(F23>12300,17+((F23-12300)/700),IF(F23>9900,10+((F23-9900)/600),IF(F23>8400,6+((F23-8400)/500),IF(F23>7200,3+((F23-7200)/400),IF(F23=7200,1))))))))

    I want to make a series of 7200-7600-8000-8400-8900-….. -19300 how can i use this formula , its not working there . plz tell me sir !

    • Mynda Treacy says

      Hi Gireesh,

      When I enter your formula into my worksheet it doesn’t return an error and appears to calculate each level correctly. When I say ‘correctly’ what I did was enter values at each logical test level and check that the result reduced, which it did.

      What results are you expecting exactly? I don’t know what you mean by ‘make a series’. Your IF formula returns the calculation in your value_if_true arguments.

      Perhaps you can send me an example workbook via the help desk.

      Kind regards,

      Mynda.

  5. Scott says

    Hi Mynda -

    I was wondering if you might be able to help with this … I’m trying to create a credit card authorization form that when choosing “AX”, “MC”, or “VI” from a drop-down in cell B1, will adjust the custom formatting in B2 to either ####-####-####-#### for VI or MC, and ####-######-##### for AX. Any thoughts? Thanks in advance.

    • Mynda Treacy says

      Hi Scott,

      You can’t toggle between custom number formats using a formula. You’d have to use VBA to do this.

      Also, you can’t display 16 digits in a cell with spaces or hyphens and keep it as a number. This means you can’t type in the 16 digits consecutively and have Excel reformat it in the same cell (without VBA).

      You’d have to type your card number in another cell and then use this combination of LEFT, MID and RIGHT functions to reformat the number in a separate cell:

      =LEFT(A1,4) & " " & MID(A1,5,4) & " " & MID(A1,9,4) & " " & RIGHT(A1,4)

      You could use an IF function (say in cell B1) with the above formula that tests the length of the card number in cell A1 and applies the above formula for 16 digits and a variation for 15 digits for the Amex. e.g.:

      =IF(LEN(A1)>15,LEFT(A1,4) & "-" & MID(A1,5,4) & "-" & MID(A1,9,4) & "-" & RIGHT(A1,4),LEFT(A1,4) & "-" & MID(A1,5,6) & "-" & MID(A1,1,5))

      I hope that helps.

      Kind regards,

      Mynda.

      • Scott says

        Thanks, Mynda. Although I wasn’t really wanting to add another cell for the data fill, then having it format in yet a different cell, I will try to figure a way to make that work. I appreciate your skills.

        On another note, the formula and formatting work great, but for some reason that I can’t seem to grasp is why the data cell (for the card # input), which is only formatted as number without decimals and data validation text length of 15-16, when 16 digits are entered it changes the last one to “0″ (i.e., 4128111122223333 becomes 4128111122223330 and formats as 4128-1111-2222-3330).

        Any thoughts? Thanks

        • Mynda Treacy says

          Hi Scott,

          Excel only stores 15 significant digits in a number. It changes digits after the fifteenth place to zeroes. This is why the last digit in a 16 digit credit card number is changed to a zero, and is also the reason you can’t use a custom number format for your credit card numbers.

          There is a more in depth explanation on numbers in Excel here.

          Your only options are to either have the number input as text with the hyphens typed in at the same time, or use a formula in another cell to convert the number to text and format it how you want.

          Kind regards,

          Mynda.

  6. Lincoln McCauley says

    Hi Mynda

    This is by far the best site I have ever visited.
    Thanks for all your hard work. Could you please put a VBA course on your site. I would’nt mind paying for the tutorials. I am new to programming and would like all the help I can get.

    • Mynda Treacy says

      Wow, thanks Lincoln :)

      We’re currently working on a VBA course. I’ll let you know when it’s ready.

      Kind regards,

      Mynda.

  7. abdulwaheed adeyemi says

    this is my first time on this site, and i can say with all sincerity, is one of the best site have ever seen. keep the good work going mynda…. more power to your elbow

    • Mynda Treacy says

      Hi Abdulwaheed,

      Thank you very much for your kind words :) I appreciate it, and my elbow is feeling stronger already!

      Mynda.

  8. rose says

    thanks ,was useful.but i need to show me in fun and animated way if possible as i cannot getiteasily,meanwhile i need it for work seriously.
    Rdgs,
    Rose

  9. Danyel says

    Hello,

    I am trying to figure out what is wrong with my if and then statements in this equation.

    = IF ((F6 >=.80), F6 x (-1)), IF ((I6=0,781350),(((0.8-F6)/(I6))*(SUM(C10:D10))/(1-((0.8-F6)/(I6)))))

    Everything after (-1)), works but the new IF command I put in is not working. I am trying to say IF cell F6 is greater than or equal to .80, then multiple F6 by -1.

    If you have a chance can you please help with this? Thanks so much.

    • says

      Hi Danyel,

      It should be like this:

      =IF(F6>=0.8,F6*-1,IF(I6=0,781350,0.8-F6/I6*SUM(C10:D10)/1-0.8-F6/I6))

      BTW, I also removed some brackets that weren’t required.

      Kind regards,

      Mynda.

  10. Harihara Achary says

    Can u help me is there any formula which autimatically change the dates from moth first to end according to the month if i will put the month in A1 ?

  11. Trevor Carpenter says

    I want to look up a value say 0.75, which is between cells, A1 has 0.5 and cell A2 has 1.0 and return a value from cell B1, as this is the lower value.

    • Carlo Estopia says

      Hi Trevor,

      I really don’t think there’s a specific look-up for this type of setup ; hence,
      I need you to send your file via help desk.
      I need to see a concrete example of your data.

      Cheers,

      CarloE

  12. Farhan Ali says

    I would appreciate if you could guide me that I am using correct formula for below condition

    I am trying to create a formula for if condition to check if an event occurs to a particular day between 17:00 hours to next day 03:00 hours then show Case 2

    case 2
    Reporting time is between 17:00 hours to next day 03.:00 hours

    =IF(AND(DAY(A2),HOUR(B2)>=17,(DAY(A2)+1),HOUR(B2)<3),"CASE4")

    • Carlo Estopia says

      Hi Farhan,

      Pardon me, But your requirement is not clear to me.

      Please send a file through HELP DESK and create some scenarios or example
      So I can understand this one.

      Cheers,

      CarloE

  13. elbert says

    good day!
    i would like to seek for your help on your spreadsheet i am working on. i would like to get the value to appear on a single cell for the following logics to consider:

    if A1 is blank then check B1, if B1 is blank then check C1, if C1 has a value the cell value will be the value on C1 example1: A1=BLANK, B1=BLANK, C1=PCS the value on the cell that will appear is PCS from C1 example2: A1=BLANK, B1=PCS, C1=BLANK the value on the cell that will appear is PCS from B1 example3 A1=PCS, B1=BLANK, C1=BLANK the value on the cell that will appear is PCS from A1

    if either or all of A1, B1 or C1 has a value, the cell value will consider any of the values on A1, B1, C1 considering A1, B1 and C1 are of equal value
    example A1 = PCS, B1 = PCS & C1 = PCS thus th value that appears on the cell id PCS

    if either one of the A1, B1 & C1 has no value considering still that the value for A1=B1 or B1=C1 or C1=A1 the cell value will take either of the value found on A1, B1 and C1 example A1=PCS, B1=BLANK, C1=PCS the value that will appear on the cell will still be PCS.

    hoping you could help me on this, am using microsoft excel 2003. thanks in advance

  14. pradip says

    I have a question, I need a formula in MS Excel 2010 to perform the following example: =if(D5=23,then(H5>11,(I5+I5*11%),if(H5>9,(I5+I5*5%),if(D5=37,then(H5>11,(I5+I5*10%),if(H5>9,(I5+I5*5%)))). I need to do this for 13 dfferent enteries in whatever contains, is that possible? Please help!

  15. Linear says

    I have a question, I need a formula in MS Excel 2010 to perform the following example: If(A2=1, then (d2<8,5,if(d2<=10,4,if(d2<=12,3,if(d213,1,if(a2=2,then(d2<6,5,if(d2<=8,4,if(d2<=10,3,if(d212,1,if(a2=3,then….. I need to do this for 13 dfferent enteries in whatever A2 contains, is that possible? Please help!

    • Carlo Estopia says

      Hi Linear,

      I have been figuring out this one, but honestly I really couldn’t get what you want here.
      Please send a file via HELP DESK with sample data and results of your logic here.

      Cheers,

      CarloE

  16. Gene Papin says

    All I want to know is how to divide my list of expenses for my hobby into categories for my accountant. (Such as office supplies, tools, etc.

    • Carlo Estopia says

      Hi Gene,

      I kind of don’t get your excel problem here.
      So why don’t you send your file to us through
      HELP DESK so we can have a good look at it.

      Cheers.

      CarloE

  17. fredy liem says

    Does any one can help me, if i want to fill the data and number without type one by one. Which formula do i need to use, for example if i am typing strawberry, the price automatic come out, from the price list which is kept in other in the other list.
    Thank you

    • Carlo Estopia says

      Hi Fredy,

      All you need is VLOOKUP and IF.

      Assumptions:
      Fredlist – is your Sheet where your masterlist is
      CurrentSheet – where your formula is

      Fredlist
      —-A——- —-B——
      1 Strawberry….3…….
      2 Apple………4…….
      CurrentList
      —-A——- —-B——
      1 InputCell…Vlookup Formula
      2 InputCell…Vlookup Formula

      Here’s what you’re going to do,
      Copy and paste the formula below.

      VLOOKUP(A1,FredList!$A$1:$B$2,2,FALSE)
      

      Please note that your lookup Value is in A1 in this example. You can adjust it depending where your
      input cell (where you type your value) is.Also the table array is only from A1 to B2, You can also
      expand it depending on how big your price list is from the other sheet. 2 is the column to return.
      Since your price is in column B then it’s in the second column starting from A. FALSE simply means
      Exact Match.

      Vlookup may return an error.
      So If you want to avoid the error,
      you can have this formula instead.

      =IF(ISERROR(VLOOKUP(A1,FredList!$A$1:$B$2,2,FALSE)),"",VLOOKUP(A1,FredList!$A$1:$B$2,2,FALSE))
      

      Read More: IF FUNCTIONS
      VLOOKUP

      Cheers.

      CarloE

  18. Elnes says

    Thank you very much. I am a bit of a novice and found the tutoral about the IF Statement very informative. Keep up the good work and God bless.

    • Carlo Estopia says

      Hi Asmae,

      I couldn’t find a previous discussion with regards to your question. Please clarify it further and I would gladly appreciate it.

      Sincerely,

      CarloE

  19. says

    Dear Sir,

    My online training is really helpful to day day activities. I have Learn most of the things like Pivot, Vlookup, H Lookup and Sumproduct.

    I really thanks to you.

    Thanks & Warm Regards

    Your online student.

    Mohammed Sofi.

  20. Brenden says

    Hello,
    I’m trying to highlight a cell with a numerical value if it is not +or- 4 of an adjacent cell. Any help would be great.
    Thank you.

    • says

      Hi Brenden,

      I’m not sure how you want to highlight a cell. Were you thinking of Conditional Formatting? Either way you can use this formula where your value you are testing is in A1:

      =A1=MEDIAN(A1,-4,4)

      This will return a TRUE or FALSE outcome.

      Kind regards,

      Mynda.

    • says

      Hi Shan,

      Thanks for your kind words.

      Unfortunately the weekly emails cannot come with PDF attachments, but if you click on the link in the emails to comment on the blog posts you can print the blog post as a PDF from the link at the bottom of the page above the comments area.

      I hope that helps.

      Kind regards,

      Mynda.

  21. Naz says

    Hi Mynda,

    I am trying to make a formula to copy the cell of another worksheet in the same workbook if it has a value next to it otherwise leave a blank cell. Eg. If cell c4in another worksheet has a value of greater than 0 then i want to display what is in cell C3 in that same worksheet other wise leave it blank. Is this possible with an IF statement?

    thanks

  22. Lou says

    Best site for Excel wannabe experts!

    How would I display current attendance points?
    Date and points are entered on Employee worksheet. Points worksheet has dates down column A and names across row 1. Points are displayed in column below each employee’s name in row for correct date. Formula on Employee worksheet should return current points in past 365 days from Points worksheet.

    Thank you!!!

    • says

      Hi Lou,

      The way your data is structured limits the solutions available, however I think perhaps the easiest is to use a DSUM function like this:

      =DSUM($A$1:$D$10,H1,$F$1:$G$2)

      Where A1:D10 is your data table, H1 containes the name of the employee you wanted to lookup, and cells F1:G2 contained your date criteria.

      You can read more about the DSUM and other database functions here.

      I hope that helps.

      Kind regards,

      Mynda.

  23. Bernie Squire says

    Hi, I’m trying to find a formula that will do the following:

    Calculate the amount of commission a person is due to be paid on an ascending scale e.g. based on the amount entered into a particular cell (lets say $30,000) I need the formula to be able to pay at 18% up to $10,000 – 35% from $10K to $15K and 45% >$15,000.

    I thought I could use an IF statement but I’m having trouble getting one to do what I need???

    Are you able to help me please?

    • says

      Hi Bernie,

      I think it’s better to use a VLOOKUP on a sorted list for this type of calculation because it’s better to house your commission rates in a separate table that you can easily update. However, if you really want to use an IF statement then this is how you’d do it:

      =IF(A1< =10000,A1*18%,IF(A1<=15000,A1*35%,A1*45%))

      Kind regards,

      Mynda.

  24. Angie says

    Hi, I am trying to create a formula that would make C3=5 if B3 has anything typed in it. How do I do that?

    Thank you!!!

    Angie

  25. Maile Uluave says

    I found excel is a very hard module that I also do not like and found this training hub very helpful and I am still trying to learn more and find more support for my study. This training explains more details of my misunderstood words in excel.

  26. M says

    Hi,
    i have come across a problem where i need to change a particular cell number in an excel formula to a new cell number where ever that number is coming in the formula (note:cell number only)
    eg here is the formula lets say master formula
    =IF((Q8-$Z$6)>21,Z8*60,IF((AND((Q8-$Z$6)>14,((Q8-$Z$6)<22))),Z8*30,IF(((Q8-$Z$6)21,AA8*60,IF((AND((Q8-$AA$6)>14,((Q8-$AA$6)<22))),AA8*30,IF(((Q8-$AA$6)=$AB$6),IF((Q8-$AB$6)>21,AB8*60,IF((AND((Q8-$AB$6)>14,((Q8-$AB$6)<22))),AB8*30,IF(((Q8-$AB$6)=$AC$6),IF((AND((Q8-$AC$6)>14,((Q8-$AC$6)<22))),AC8*30,IF(((Q8-$AC$6)=$AD$6),(IF((Q8-$AD$6)>21,AD8*60,IF((AND((Q8-$AD$6)>14,((Q8-$AD$6)<22))),AD8*30,IF(((Q8-$AD$6)<=14),AD8*20)))))

    and where ever the number 6 is coming in the above formula, i want to replace it with 102 keeping the rest formula same. I'l b glad if u could help me out.
    Regards

    • Mynda Treacy says

      Hi M,

      1. Select the cells containing the formulas you want to change.
      2. CTRL+H to open Find and Replace:
      3. In the Find field enter: $6
      4. In the Replace field enter: $102

      Kind regards,

      Mynda.

      • M says

        Mynda i can’t imagine how you respond to all these queries so promptly, all my appreciation for that.
        i want help in another thing, i want to use the following three formulas together such that if any one of the formula holds for the cell AA16, then it gives that respective value.so my question is how these can be combined when i know that Z17 can take either of the three scenarios but not all or even two at a time.

        IF((Z17>=0),(AA16))
        IF((Z17=-1),(AA16-Z17-N17))
        IF((Z17=””),(AA16-N17))

        best regards

        • M says

          i also want to know is there a way to bring in a row certain values from a range of cells..i’l explain, lets say in column B i have a range of dates say like this
          5-july
          5-july
          5-july
          5-july
          8-aug
          8-aug
          10-sep
          10-sep
          i want to make a formula, that will make for me a row (using aforementioned column) 5-july 8-aug 10-sep placed in cells E6 to G6.so my question is, can i get single values of all the different dates present in the columnB in row6 without giving a command to specifically look for 5-july 8-aug 10-sept, what it should look for is rather single values of different dates present and bring them in ascending order in the row.
          i’m sorry for not being concise.
          many thanks

          • says

            Hi again, M,

            Let’s say your dates are in cells A2:A9. Enter this formula in cell B1:

            =IFERROR(INDEX($A$2:$A$9,MATCH(0,COUNTIF($A$1:A1,$A$2:$A$9),0)),"")

            This is an array formula so you need to enter it with CTRL+SHIFT+ENTER

            You can then drag to copy the formula across the remaining columns.

            Kind regards,

            Mynda.

        • Mynda Treacy says

          Hi M,

          You’re almost there with your formula. It’s:

          IF(Z17>=0,AA16,IF(Z17=-1,AA16-Z17-N17,IF(Z17=””,AA16-N17,0)))

          Kind regards,

          Mynda.

          • M says

            Thanku so very much Mynda.
            i am somehow encountering a problem when i enter these formulae.
            excell pops up a box for both the formulas that “formula contains an error”. i’l be grateful if u can give it another look.

            kind regards

          • says

            Hi M,

            It’s most likely the formatting of the double quotes. I’d delete them and type them in again. When I enter them in the comments the format of them is changed and not compatible with Excel.

            Please let me know if that doesn’t fix it.

            Kind regards,

            Mynda.

          • Darren says

            I have thought about how to ask my question correctly, I believe this more appropriate.

            I am using this formula in excel 2010, “=IF(ISBLANK(P7),””,IF(P70,H7-P7)/0.25),IF(I7>P7-I7)/0.25)))”

            which is not being accepted and displays a message “too many arguments for this function” with only the last section 0.25 highlighted.

            Values only are required to be entered in either H7 or I7 but not both. P7 is the end result of entry from either H7 or I7 with Q7 providing a breakdown of P7 result, the reason for /0.25.

            If I enter the formulas individually into Q7, “=IF(ISBLANK(P7),””,IF(P70,H7-P7)/0.25))” the correct result is displayed when a value is entered into H7 & when reversed “=IF(ISBLANK(P8),””,IF(I7>0,P7-I7)/0.25))” with an entry in I7 a correct answer is given as it should, though not with the combined formula as when I join the two I cannot get it to work.

            I have tried ending with; ,””))) & removing P7>0, & I7>0, also tried SUM in place of IF also without success.

            What have I done incorrectly?

          • Carlo Estopia says

            Hi Darren,

            Basics First:
            The IF function, nested IFs
            IF(CONDITION, TRUE VALUE, FALSE VALUE)
            IF(CONDITION, TRUE VALUE) —FALSE VALUE is assumed FALSE if left out
            NESTED:
            IF(CONDITION, TRUE VALUE, FALSE VALUE: another IF(CONDITION, TRUE VALUE, FALSE VALUE)
            Note : It’s easy… don’t mess your condition with your true values and false values.

            Let’s break your formula down: “=IF(ISBLANK(P7),””,IF(P70,H7-P7)/0.25),IF(I7>P7-I7)/0.25)))”
            good:=IF(ISBLANK(P7),””, – IF(CONDITION, TRUE VALUE,
            bad:=IF(P70…. what’s your condition here?P7>0?
            bad:IF(P70,H7-P7)/.025 … you’re mixing your condition with your true value
            however you said it works when isolated it’s because IF(P7>0,H7-P7) complies with IF(CONDITION,TRUE VALUE)
            bad: ,IF(I7>P7-I7)/0.25))) this part is in excess of the first IF’s arguments. see you have the “” -TRUE VALUE and
            the second IF as your FALSE VALUE… you can’t have another IF unless you will put it in the FALSE Value part of \
            the second IF.

            I have here your formula but honestly I do not know your conditions and what you want to do
            when those conditions are true or not.

            =IF(ISBLANK(P7),"",IF(P7>0,(H7-P7)/0.25,IF(I7>(P7-I7)/0.25,"TRUE VALUE HERE","FALSE VALUE HERE")))
            

            EXPLANATION OF FORMULA: you have 3 nested IFS
            IF condition: P7 = blank then
            true value:formula result is blank
            false value: another IF
            IF P7>0 then
            true value:(H7-P7)/.025
            false value: another IF
            IF I7>(P7-I7)/.025
            true value: “TRUE VALUE HERE”
            false value: “FALSE VALUE HERE”

            Read More on NESTED IFS

            Cheers.

            CarloE

          • Carlo Estopia says

            Darren,

            On behalf of Mynda, You’re Welcome.
            We should thank Mynda for this
            wonderful site.

            Cheers.

            Carlo

          • Darren says

            I solved it;

            =IF(ISBLANK(C4),””,IF(A4>0,(A4-C4)/0.25,IF(B4>0,((C4-B4)/0.25),””)))

            this works.

  27. Dan Kim says

    thanks. very succinct.

    was wondering about how to do the following…

    I want a cell to be outlined with a border if the value of a specific different cell is less than or equal to 40%…

    If $C$7 <=40%… not sure about the rest. btw…using excel07

    thanks in advance

    • Mynda Treacy says

      Hi Jack,

      I’m sorry, we don’t have a PDF of the above tutorial. You could try printing the page as a PDF if you wanted to keep it offline.

      Kind regards,

      Mynda.

  28. Melissa says

    How do I use the “IF” Statement to determine how many days are in between two cells and if they are more is it possible to add an “X” next to those that are?

    • Mynda Treacy says

      Hi Melissa,

      You can use the DATEDIF function to calculate the number of days between two dates.

      Let’s say you want to know if the number of days between the date in cell A1 and date in cell B1 is > 5. If it is put an “X” if not enter nothing “”, you’d use this formula in column C:

      =IF(DATEDIF(A1,B1,”D”)>5,”X”,””)

      I hope that helps.

      Kind regards,

      Mynda.

      • Shyam says

        Hey Mynda,

        Its absolutely made the way I use excel easier….it looks so beautiful
        Hah….nonetheless, I couldn’t find a clue as to why “D” in the formula – =IF(DATEDIF(A1,B1,”D”)>5,”X”,””) – is used. I tried to put a different alphabet, but it didn’t work. Could you please shed some light on the role of “D” in the formula in question?

        Thank u

  29. nancy says

    I am looking for help I want to use the if formula but I want the if to post the whole row on a separate tab in the workbook with 5 different options keeping the information on my work sheet so as I add information the information will change on the other tab ….link …..maybe that would be better

      • nancy says

        =if(column b) is Shoes row 22 will post. Information on shoe tab and keep in shipping date order (column f)

        If that in not possible can you direct me to where I should be asking or am I totally asking for the impossible

        • Mynda Treacy says

          Hi Nancy,

          I have many questions about what you’re trying to do which would be best answered by you sending me the file so I can see exactly how your data is laid out and what you mean by ‘keep in shipping date order’ etc.

          Please go to the help desk and fill out a ticket and attach your file with the example and instructions of what you want to do.

          Thanks,

          Mynda.

  30. Mohammed Shukur Sheikh says

    Sir, It is good and excellent explained and I would like to say nobody explain like this.And further I hope you would explain all the difficult problems and the equations speciaaly

  31. faisal bashir says

    Video tutorial is the most effective way of learning with enjoyment.
    Thank you so very much Mynda treacy and team for your excellent vision, efforts and the lust to spread knowledge.

    Wishing you all the best

    Regards,
    Faisal Bashir.

  32. Rose Tegg says

    I am learning so much, your explanations are very easy to follow. I have enjoyed doing the learning the IF statement. Thank you

  33. charles says

    how do I test to see if a number falls within a range and how do I write the formula? should I use the IF AND function?

    • Mynda Treacy says

      Hi Charles,

      You could use a formula like this:

      =IF(AND(A1>=5,A1<=10),"TRUE","FALSE")

      Which says, IF the value in cell A1 is between 5 and 10 then return 'TRUE', if not return'FALSE'.

      I hope that's what you're after.

      Kind regards,

      Mynda.

Trackbacks