+ Reply to Thread
Results 1 to 7 of 7

Searching through the values with condition

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    Haifa, Israel
    MS-Off Ver
    Excel 2007
    Posts
    5

    Searching through the values with condition

    Hello,
    I have a list of points. Each point has x and y coordinates. I also have cells. Each cell has 4 boundaries - left, right, top and bottom. I need to create a function for each cell that will run through the list of points and if it finds a point that it's x coordinate is bigger than left boundary and smaller than right boundary and y coordinate is bigger than bottom boundary and smaller than top boundary, function will put a "1" in a cell. If it runs through all the points and doesn't find such a point - function will put a "0" in a cell.

    I will give an example:
    func.GIF

    I need to enter a function to cells G5 and G6. Function in cell G5 will run through x and y coordinates of point and will find a point #1 which x coordinate is indeed left<x<right and bottom<y<top, so G5 cell will receive a "1" value. On the other hand, function in cell G6 will run through the points' x and y coordinates and will not find any point that fits the requirements and G6 will receive a "0" value.

    Can somebody help me with writing such a function?
    Many thanks!

    Georgiy.
    Last edited by LmdL; 04-26-2013 at 09:56 AM.

  2. #2
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: Searching through the values with condition

    Searching through the values with condition.xlsx
    This is what i understand your question. Hope it help
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

  3. #3
    Registered User
    Join Date
    04-25-2013
    Location
    Haifa, Israel
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Searching through the values with condition

    Thank you, wenqq3!
    But in your example, cell 2 received "1", but there is no point that it's x is between 2<x<3 and y such 5<y<6, so it was supposed to receive a "0".


    I mean, function in each cell should contain constraints on both X and Y - so cell should receive "1" only if X and Y coordinates of some point fit the cell's boundaries.
    Last edited by LmdL; 04-26-2013 at 07:30 AM.

  4. #4
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Searching through the values with condition

    Hello,

    Please check if the attached file is what you are looking for.
    Attached Files Attached Files
    (copy pasta from Ford)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools

    Regards,
    Lem

  5. #5
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Searching through the values with condition

    An alternative is to use the following formula
    Please Login or Register  to view this content.
    This one is not an array formula. You can paste it on B10 on the sample file and drag it down.

  6. #6
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: Searching through the values with condition

    Lemice 's answer should be the one you want

  7. #7
    Registered User
    Join Date
    04-25-2013
    Location
    Haifa, Israel
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Searching through the values with condition

    Lemice, thanks! Your formula indeed works!
    Thank you very much!

+ 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