+ Reply to Thread
Results 1 to 5 of 5

VLOOKUP gives wrong result with TRUE for range-lookup

  1. #1
    Registered User
    Join Date
    12-07-2011
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    30

    VLOOKUP gives wrong result with TRUE for range-lookup

    I have a rather large table of data (whole table is ~800 columns by ~2700 rows) from which I need to extract a few rows at a time chosen by the value in column A. I therefore created a second sheet with the column headers and a VLOOKUP function. I paste the desired values into column A and it returns the desired rows.

    The problem, however, is that if I use "TRUE" for the range_lookup value, many of the rows do not return the correct information but return the information for another row instead. The attached example spreadsheet is a cut down version of the original, with most of the columns removed to shrink the file size. When I tried removing some of the rows as well, it changed the results significantly. Even if I removed some rows that seemed to play no part (were neither the row referenced or the row returned incorrectly), some of the rows began to return the right values, and others returned different, but still wrong, values. One would think that this is just a case of Excel finding the closest value, but in this case, the value being looked up is simply copied and pasted from the table.

    If I use "FALSE" for the range-lookup value, it fixes the problem, but it comes at a significant performance penalty. It's no big deal for this spreadsheet, but I have another one that does something similar with the same dataset for which the performance penalty is much larger. If I use "TRUE", it takes about 3 minutes to calculate the spreadsheet, but if I use "FALSE", it takes about 20 minutes. I'm not worried about getting #N/A values because I know the lookup values are in the table, but now I don't think I can trust the results unless I can figure out why it's not working properly and fix it.

    Does VLOOKUP have a problem when the lookup array is too large?
    Attached Files Attached Files
    Last edited by drfarmkid; 02-06-2013 at 06:50 PM.

  2. #2
    Registered User
    Join Date
    04-30-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2013
    Posts
    59

    Re: VLOOKUP gives wrong result with TRUE for range-lookup

    Does this work?
    Attached Files Attached Files

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

    Re: VLOOKUP gives wrong result with TRUE for range-lookup

    if you use TRUE the range has to be sorted ascending
    from the help file
    If range_lookup is TRUE, the values in the first column of table_array must be placed in ascending order: ..., -2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE; otherwise VLOOKUP may not give the correct value. If range_lookup is FALSE, table_array does not need to be sorted.
    Last edited by martindwilson; 02-06-2013 at 05:53 PM.
    "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

  4. #4
    Registered User
    Join Date
    12-07-2011
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: VLOOKUP gives wrong result with TRUE for range-lookup

    Ah yes, that's the problem. The data isn't sorted. I knew it was supposed to be, but just never made the connection for some reason. I'm used to always using FALSE so I never had to think about whether the data was sorted and didn't think of it this time. Thanks for the reminder.

    In this case, I can't sort the data for other reasons, so I'll just have to live with the calculation time hit.

    jph89 Yes, that does work. Thanks.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: VLOOKUP gives wrong result with TRUE for range-lookup

    If you want to speed up calculations without sorting then perhaps use INDEX/MATCH as per jph's suggestion but instead of repeating the same MATCH function multiple times on each row you could have a single "helper" column with the MATCH function and then the INDEX function for every cell in that row can reference the same MATCH function.....
    Audere est facere

+ 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