+ Reply to Thread
Results 1 to 7 of 7

Setting ranges for comparison operators

  1. #1
    Registered User
    Join Date
    06-26-2009
    Location
    O.o
    MS-Off Ver
    Excel 2003
    Posts
    64

    Setting ranges for comparison operators

    Hi everyone,

    Is it possible to set a range using comparison operators? ie. if a number lies within x and y then such and such happens.

    To be more precise:

    Please Login or Register  to view this content.
    Focusing on the red text, I was hoping to set english and science so that they are also < 70 (lie between 50 - 69).

    Thanks for your time!
    Last edited by dems; 07-22-2009 at 10:14 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Setting ranges for comparison operators

    Not sure of the logic you're trying to apply. Maybe this:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Setting ranges for comparison operators

    hi Dems,

    I think you have given the answer to your own question in your example (once corrected by changing the red "70" to a "50")...?

    Here's a very slightly alternative approach to your function, using Long for the arguments which may be slightly faster for large data sets, because I think that Double is "overkill". Note that the order of the tests in the function means that the range of 50-69 is already "defined" within the second Case, because the arguments have failed the initial test (ie ">=70") but do pass the ">50" test.

    Please Login or Register  to view this content.
    If you need more help let us know

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Setting ranges for comparison operators

    Shg, you beat me to it again - good to see that I'm starting to think similarly to yourself though

    Although, I do like your use of the .min function because this would mean changes would only need to be made in the Function's arguments & the .min line of code if (or when) the function is modified to allow for more subjects.

    Rob

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Setting ranges for comparison operators

    I dunno, Rob, don't know what the OP is trying to do. Many roads lead to Rome.

  6. #6
    Registered User
    Join Date
    06-26-2009
    Location
    O.o
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: Setting ranges for comparison operators

    Thanks gentlemen, you have been verty helpful! I will definately spend some time reading further into case statements and worksheetfunction.min/max, but both yield the result I was looking for, which was to analyse 3 test results and report a grade in relation to the test results. Once more, thank you.

  7. #7
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Setting ranges for comparison operators

    I'm pleased we could help - thanks for the feedback

    Rob

+ 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