+ Reply to Thread
Results 1 to 10 of 10

Determine if a cell value is within upper and lower bounds?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Determine if a cell value is within upper and lower bounds?

    Hi guys,

    This should be an easy one, but it isn't working in Excel for me.

    I basically want to do this formula:

    IF((Setpoint-0.6) <= Result <= (Setpoint+0.6), "OK", "FAIL")

    It does not work because of how Excel treats comparisons. I've tried doing something like IF(Result => (Setpoint-0.6) AND Result <= (Setpoint+0.6), "OK, "FAIL") but it just gives me a #NAME? error.

    Any way of doing this?
    Last edited by Darksabre; 06-03-2013 at 01:13 PM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Determine if a cell value is within upper and lower bounds?

    Try

    =IF(ABS(Setpoint-Result)<=0.6,"OK","FAIL")

  3. #3
    Registered User
    Join Date
    06-03-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Determine if a cell value is within upper and lower bounds?

    Quote Originally Posted by Jonmo1 View Post
    Try

    =IF(ABS(Setpoint-Result)<=0.6,"OK","FAIL")
    This also works just fine. Different way of thinking about the comparison. I like it.

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: Determine if a cell value is within upper and lower bounds?

    =IF(AND(Result>=Setpoint-0.6,Result<=Setpoint+0.6), "OK", "FAIL")
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  5. #5
    Registered User
    Join Date
    06-03-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Determine if a cell value is within upper and lower bounds?

    Quote Originally Posted by Special-K View Post
    =IF(AND(Result>=Setpoint-0.6,Result<=Setpoint+0.6), "OK", "FAIL")
    This worked right away. I should have read up on the usage of AND in Excel. I just came from programming a lot of Python scripts, so that's where my mind was, haha.

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Determine if a cell value is within upper and lower bounds?

    A1: test number....12
    B1: setpoint.....20
    C1: tolerance...5

    This regular formula returns OK if the test number is within the tolerance of the setpoint...otherwise Fail:
    D1: =IF(MEDIAN(A1,B1-C1,B1+C1)=A1,"OK","Fail")

    In the above example, the formula returns: Fail...because 12 is not between 15 and 25, inclusive.
    If you change A1 to 16, the formula returns: OK

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  7. #7
    Registered User
    Join Date
    06-03-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Determine if a cell value is within upper and lower bounds?

    Quote Originally Posted by Ron Coderre View Post
    A1: test number....12
    B1: setpoint.....20
    C1: tolerance...5

    This regular formula returns OK if the test number is within the tolerance of the setpoint...otherwise Fail:
    D1: =IF(MEDIAN(A1,B1-C1,B1+C1)=A1,"OK","Fail")

    In the above example, the formula returns: Fail...because 12 is not between 15 and 25, inclusive.
    If you change A1 to 16, the formula returns: OK

    Is that something you can work with?
    I had not used the MEDIAN function before. It looks like something I could use as well. Thanks for the help.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,370

    Re: Determine if a cell value is within upper and lower bounds?

    Hi Darksabre and welcome to the forum,

    I think you need to use the syntax of

    =If(AND(Setpoint - .6 <= Result , Setpoint + .6 >= Result),"ok","fail")

    See http://spreadsheets.about.com/od/exc...080117_and.htm for some other examples.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  9. #9
    Registered User
    Join Date
    06-03-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Determine if a cell value is within upper and lower bounds?

    Quote Originally Posted by MarvinP View Post
    Hi Darksabre and welcome to the forum,

    I think you need to use the syntax of

    =If(AND(Setpoint - .6 <= Result , Setpoint + .6 >= Result),"ok","fail")

    See http://spreadsheets.about.com/od/exc...080117_and.htm for some other examples.
    Thanks for the welcome

    Yes, you are right - as Special-K showed, that is indeed the Syntax for the AND. Thanks for the link also.

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Determine if a cell value is within upper and lower bounds?

    Glad to help, thanks for the feedback.

+ 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