+ Reply to Thread
Results 1 to 17 of 17

IF Statement Inquiry

  1. #1
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    IF Statement Inquiry

    Hi Everyone.

    I am working with this IF statement =IF(ABS(B2)<=0.02,1,"ERROR") I have this formula in cell A1. The problem is, I want the IF statement to include 3 other cells C2, D2 and E2 but not sure how to accomplish this.

    Thank you for the assistance.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF Statement Inquiry

    Include them how? Do you want to check if all are less than 0.02?

    =IF(AND(ABS(B2)<=0.02,ABS(C2)<=0.02,ABS(D2)<=0.02,ABS(E2)<=0.02),1,"ERROR")

    Do you want to check if any are less than 0.02?

    =IF(OR(ABS(B2)<=0.02,ABS(C2)<=0.02,ABS(D2)<=0.02,ABS(E2)<=0.02),1,"ERROR")

    or the sum of them

    =IF((ABS(SUM(B2:E2))<=0.02,1,"ERROR")

    or something else?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    B2, C2, D2 and E2 all have a formula in it. The formula is the results of the difference from 2 other cells. When the results in cell B2, C2, D2 and E2 are + 2 cents to - 2 cents which is an acceptable variance in this case, I would like the number 1 show up in cell A1. If the results of those cells has a greater variance of + 2 cents or - 2 cents, I would like ERROR show up in cell A1.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF Statement Inquiry

    So then maybe the first formula I gave you?

  5. #5
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    Thank you so much! That 1st formula worked. Much appreciated.

  6. #6
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    I have noticed using this formula =IF(AND(ABS(B2)<=0.02,ABS(C2)<=0.02,ABS(D2)<=0.02,ABS(E2)<=0.02),1,"ERROR") only works when there is a value in cell B2 which is great but I sometimes do not have a value in B2. I have also used the other suggested formula =IF(OR(ABS(B2)<=0.02,ABS(C2)<=0.02,ABS(D2)<=0.02,ABS(E2)<=0.02),1,"ERROR") and the results always shows up as 1 even if there is a variance greater then + or - 2 cents in cells B2, C2, D2 or E2. I am not sure why this OR Statement is not recognizing to answer "ERROR" when there is a value greater then + or -2 cents.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF Statement Inquiry

    The AND checks that all the cells have a number with +/-0.02 variance.

    The OR statement checks if any of the cells have a number with +/-0.02 variation. Only one needs to have it for a 1 to appear.

    So I am not sure what you are needing? Do you want to get a 1 if any one only cell has a variance?

  8. #8
    Registered User
    Join Date
    03-26-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: IF Statement Inquiry

    Try this:

    =if(max(abs(b2:e2))<=0.02,1,"error")

    As this formula involves an array you have to hit ctrl + shift + enter for it to work.

  9. #9
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    Hi NBVC,

    Thanks for your replies. When ever there is a variance in any of the cells B2, C2, D2 or E2, I would like "Error" to show up when the variance is greater then +/- 2 cents. So if the cell has a value of 3 cents or higher or - 3 cents, -4 cents...etc, "Error" is the result. If any one of the cells has a value of -0.02, -0.01, 0, 1 or 2, I need "1" to shows up.

    Also thank you Down Under for your reply. I have tried your formula but got a "#VALUE!" error.

  10. #10
    Registered User
    Join Date
    03-26-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: IF Statement Inquiry

    Did you remember to hit ctrl + shift + enter instead of just enter? I've tried it again on my workbook and it still works fine.

  11. #11
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    I have hit ctrl + shift + enter and the formula executed but have noticed that I need a value in cell B2 for it to work. If B2 is blank, the formula does not work.

  12. #12
    Registered User
    Join Date
    03-26-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: IF Statement Inquiry

    Hmm, it works okay on mine if B2 blank. See if this works.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    I see that it does work on your spreadsheet but not sure why it would not work on mine.

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF Statement Inquiry

    Quote Originally Posted by Opus1 View Post
    Hi NBVC,

    Thanks for your replies. When ever there is a variance in any of the cells B2, C2, D2 or E2, I would like "Error" to show up when the variance is greater then +/- 2 cents. So if the cell has a value of 3 cents or higher or - 3 cents, -4 cents...etc, "Error" is the result. If any one of the cells has a value of -0.02, -0.01, 0, 1 or 2, I need "1" to shows up.

    .
    Probably need the OR with operations reversed...

    e.g

    =IF(OR(ABS(B2)>0.02,ABS(C2)>0.02,ABS(D2)>0.02,ABS(E2)>0.02),"ERROR",1)

  15. #15
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: IF Statement Inquiry

    Did the reverse work?

  16. #16
    Registered User
    Join Date
    03-19-2012
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: IF Statement Inquiry

    Yes, I have used this formula =IF(OR(ABS(B2)>0.02,ABS(C2)>0.02,ABS(D2)>0.02,ABS(E2)>0.02),"ERROR",1) and it has worked
    I appreciate all the assistance.

  17. #17
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: IF Statement Inquiry

    Can you mark this as solved please.
    If someone helped give them rep using the star button.

    If you have received a satisfactory solution please mark the thread solved. If not Fotis will come for you at night :P

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1