+ Reply to Thread
Results 1 to 5 of 5

Lookup Formula: why does this work

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Lookup Formula: why does this work

    In A previous post,

    http://www.excelforum.com/excel-gene...ain-value.html

    in which the OP was trying to find the maximum date (Col B) in which the value in Col A occurred, DonkeyOte used this formula as a possible solution
    Please Login or Register  to view this content.
    I understand the formula somewhat; 1/Sheet1!A1:A100=A1 will give either Infinity (or #DiV/0) or a 1. However, since the values in A are not in order (thus giving a search of something like 1, #DIV, # DIV, 1, ...) how would the formula know when the last value is? Does it go to the end and work backwards?

    Thanks
    Last edited by ChemistB; 11-10-2009 at 12:04 PM.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Lookup Formula: why does this work

    Here is one of my previous explanations to that....

    http://www.excelforum.com/excel-gene...ml#post1997590
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Lookup Formula: why does this work

    Key points re: LOOKUP function

    a) it will return last value <= criteria

    b) it ignores any/all values within the lookup_vector not of the same data type as that of the criteria value - note (importantly) this includes errors.

    c) it assumes lookup_vector is sorted in ascending order at all times (regardless of reality) and thus assumes last found value to be the biggest

    So using the example

    =LOOKUP(2,1/(Sheet1!$A$1:$A$100=$A1),Sheet1!$B$1:$B$100)

    the lookup_vector we know will be populated with only 1 or #DIV/0! - the criteria set to 2 is thus bigger than all possible numerical values in lookup_vector - given the nature of LOOKUP we know then that this will ensure the last numerical value (1) is returned... or where the result_vector is in use (as is the case here) the associated value.

    In the link - we know the dates are listed in ascending order and thus the last instance is the max date - on that basis we use LOOKUP to find last instance of criteria (where 1/Boolean returns 1) and return associated date.
    Last edited by DonkeyOte; 11-10-2009 at 11:15 AM. Reason: typo

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Lookup Formula: why does this work

    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup Formula: why does this work

    Thanks to all. I should have realized that the error values would not be considered. Sighhh

+ 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