+ Reply to Thread
Results 1 to 5 of 5

Searching an array.

  1. #1
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Searching an array.

    I need to do the following:
    I have a horizonal row of numbers X1, . . . , Xn.
    I have a corresponding horizontal row of numbers Y1, . . . ,Yn.
    I want to search the Y row to find the first value (going from left to right) less than some value. Then return the corresponding X row value.
    I tried used the MATCH and HLOOKUP functions, nothing seems to work because I am an Excel n00b.

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

    Re: Searching an array.

    Try a structure something like this:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Searching an array.

    Ok so I probably need to show an example.

    If I have this row: 0 1 2 3 4 5 6 7 8 9 10
    And this row below it: 25 20 15 10 5 0 -5 -10 -15 -20 -25
    And I want to find the first value in the second row less than -18 and then return the corresponding value in the first row which would be 9. But I will give your code a try.

  4. #4
    Registered User
    Join Date
    05-12-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Searching an array.

    Well I understand the INDEX part but not MATCH. I use the value 1 to indicate less than but it always comes up with the last column.

    EDIT: With the last column in MATCH as -1 I get the correct answer. I will check for errors but problem is most likely solved.
    Last edited by Fusiontron; 05-12-2014 at 03:24 PM.

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

    Re: Searching an array.

    OK...
    With your sample data in A1:K2
    this regular formula returns the first A1:K1 value where the corresponding Row_2 value is less than -18:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Is that something you can work with?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Searching for a value within an array
    By jsgreen15 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-09-2014, 10:42 AM
  2. Array searching
    By DarCady in forum Excel General
    Replies: 1
    Last Post: 09-15-2009, 03:02 AM
  3. [SOLVED] Searching for a value in an Array
    By Farah in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-21-2006, 09:15 AM
  4. searching in an array
    By sisko101 in forum Excel General
    Replies: 1
    Last Post: 08-04-2005, 06:05 PM
  5. Array Searching - HELP!
    By astro_al in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2005, 09:59 AM

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