+ Reply to Thread
Results 1 to 6 of 6

Using If/Then/Else statements with ranges of data

  1. #1
    Registered User
    Join Date
    02-20-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Using If/Then/Else statements with ranges of data

    Hello!
    Let me start off by saying I'm an excel newbie (I just started using formulas today).
    However, I have a rather complex task I'm trying to accomplish. I have almost no knowledge of excel formulas/coding so I'll try to explain in just words.

    I have several ranges of data and I would like to see if any values of this range overlap with another range.

    Say column A is the lower limit of one range, B is the upper limit. Column C is the lower limit of a second range, D is the upper limit, etc.

    I'm wanting to check if any of these ranges (A to B, or C to D, etc) completely or partially overlap with the range 30<x<=60.

    I would like to get a "1" in the cell if there is any overlap and a "0" if there is none.

    I'm guessing the code/formula would have to say something like this (please forgive me for not putting this in proper excel language):

    If A<=x<=B overlaps with 30<x<=60 then cell = 1
    else if C<=x<=D overlaps with 30<x<=60 then cell = 1
    else cell = 0

    I'm not even sure if this is possible.

    Thank you so much!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Using If/Then/Else statements with ranges of data

    probably doable post a workbook with sample ranges and expected reults
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    02-20-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Using If/Then/Else statements with ranges of data

    Sorry, how do I post a sample workbook?

    I did some googling and found an "intersect" function which looks like it could determine if ranges overlap. I'm not sure how it to use it though.
    http://www.ozgrid.com/VBA/vba-intersect.htm
    I'm not sure if this is the right thing.

    I was also wondering how does VB relate to excel? I once used VB ages ago. Would I need it to do this excel function or can I just use excel?

  4. #4
    Registered User
    Join Date
    02-20-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Using If/Then/Else statements with ranges of data

    I tried to make a simplied example of what I want. Let me know if this helps!
    Attached Files Attached Files

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Using If/Then/Else statements with ranges of data

    i dont see why how you get results
    0 20 40 90
    you have as 1 but 0 and 20 is outside range

  6. #6
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Using If/Then/Else statements with ranges of data

    I'm wanting to check if any of these ranges (A to B, or C to D, etc) completely or partially overlap with the range 30<x<=60.
    Try the formula below
    Please Login or Register  to view this content.
    This will return "1" if either A to B or C to D (or both) overlap with 30<x<=60. However your example shows "0" when C to D is 25 to 40 which surely does overlap and so should be "1" as given by the formula.

+ 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