+ Reply to Thread
Results 1 to 8 of 8

Return First Match Value

  1. #1
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Return First Match Value

    Hi,

    I have the following code for lookup a value on a range and return back the result from another range.
    The code runs okay the only thing is that is NOT returning the first match and I would like it to return the first value that has been found.

    Please Login or Register  to view this content.
    Thanks!

    Kind regards

  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: Return First Match Value

    is the data in the lookup range sorted ascending?
    "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
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Return First Match Value

    Yes, the range from column "E" is ascending.

    Maybe is useful to know that there are hidden cells in the lookup range.

    Regards

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

    Re: Return First Match Value

    hiddent wont matter its whats in them that does, what is in the whole range of column e
    do you get the same resulys with using the worksheet function directly in the work sheet?
    =lookup("x",E17:e1000,ab17:ab1000)
    Last edited by martindwilson; 02-17-2014 at 01:14 PM.

  5. #5
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Return First Match Value

    hi pezalmendra!

    have you tryied like this?
    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  6. #6
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Return First Match Value

    That formula will return the second value from the range (as the code I posted). I am interested in the first value that match that condition...

  7. #7
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Return First Match Value

    bulina2k your code works excellent!

    Thank you very much!!

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

    Re: Return First Match Value

    well glad thats fixed but lookup will work if range sorted correctly and no duplicates or it finds the last so that was your problem
    =LOOKUP(2,{1,1,1,2,2,2,3,4,5,6},{1,2,3,4,5,6,7,8,9,10}) would return 6

+ 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. Replies: 5
    Last Post: 10-16-2016, 02:33 AM
  2. Replies: 3
    Last Post: 05-08-2013, 02:10 PM
  3. Match string in one column, return value in same row, skip rows that down't match
    By anilsen0711 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 05:35 AM
  4. [SOLVED] Two Excel sheets trying to match text data and return the match from the second column!
    By bankcott in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-02-2013, 02:17 PM
  5. Replies: 5
    Last Post: 10-11-2008, 04:01 PM

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