+ Reply to Thread
Results 1 to 4 of 4

Determine if a value falls within a horizontal and vertial range

  1. #1
    Registered User
    Join Date
    10-31-2012
    Location
    Maryland, United States
    MS-Off Ver
    Excel 2003
    Posts
    3

    Determine if a value falls within a horizontal and vertial range

    What I am trying to do is determine if a value, for example 501, falls withing a a series of ranges. So there is a range 502:543 and i need to check if the value falls in that range, while also checking if the value falls between many other ranges. The second range I need to check is between 545:1000 and so on. I have attached a few examples ranges in the spreadsheet. The values in column E all need to be cheked if the fall within 502:543 and 545:1000 and so on. I have thousands of ranges and values I need to check so I can not do in manually. I tried a forumla in column F, but that does not seem to work porperly. If the value is changed to 502 then the countif function reuturns a 1, which is what I want. However, when I change the value in to 503 the formula still returns a 0, which should not be the case since 503 is within the range of 502:543. If this cannot be done with a forumla, but can be done with VBA somehow I am open to any suggestions.

    p.s. I used =countif just so i could get a simple binary yes/no result. an =if could also work in theory, I just like countif for some reason.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Determine if a value falls within a horizontal and vertial range

    Put this formula in F2 and copy down. It will tell you how many of the ranges that value falls between. Expand the ranges as needed.

    =SUMPRODUCT(--($A$2:$A$15<=E2), --($B$2:$B$15>=E2))


    This formula is conducting two tests and only counts a "1" when both tests equate to TRUE for a pair of values in A:B. None of the values in your sample sheet match any of the sample ranges.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-31-2012
    Location
    Maryland, United States
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Determine if a value falls within a horizontal and vertial range

    This looks like it did the trick. Thanks so much for your help !
    Last edited by JBeaucaire; 10-31-2012 at 05:13 PM. Reason: Removed whole post quote, unnecessary

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Determine if a value falls within a horizontal and vertial range

    I have marked this thread solved for you.
    In the future please select Thread Tools from the menu above and mark the thread as solved. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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