+ Reply to Thread
Results 1 to 5 of 5

backward lookup

  1. #1
    Registered User
    Join Date
    01-03-2007
    Posts
    31

    backward lookup

    I have dates in column A in ascending order. In column B i have numbers. There are no blank cells. I want to do a lookup for a selected date, and return the number corresponding to that date (from column B). If the number is zero, i want to return the first non zero number BEFORE the selected date. So moving backwards. Is this doable?

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Given your data in A1:A100 and B1:B100 you could use this formula:

    =INDEX($B$1:$B$100,MAX(IF($A$1:$A$100<=D1,IF($B$1:$B$100<>0,ROW($A$1:$A$100)-ROW($A$1)+1))))

    Confirmed with Ctrl+Shift+Enter (it's an array formula).

    Best regards

    Richard

  3. #3
    Forum Contributor
    Join Date
    10-30-2007
    Location
    Norway
    MS-Off Ver
    MS Office 2007
    Posts
    345
    Or this solution:

    Add a help column C to index the data in column B, this column can you hide.

    Lookup formulas like this can be pretty scary at first, but in my attachment I explains step by step how you find the right value using INDEX and MATCH formulas.
    Attached Files Attached Files

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Try this to work with any numbers in column B

    =LOOKUP(9.999999999999E+307,IF(A1:A100<=D1,IF( B1:B100>0,B1:B100)))

    confirmed with CTRL+SHIFT+ENTER

    If you just have integers in B

    =1/LOOKUP(2,1/(B1:INDEX(B:B,MATCH(D1,A:A,0))))

  5. #5
    Forum Contributor
    Join Date
    10-30-2007
    Location
    Norway
    MS-Off Ver
    MS Office 2007
    Posts
    345

    Thumbs up

    =1/LOOKUP(2,1/(B1:INDEX(B:B,MATCH(D1,A:A,0))))
    I guess you didn't find this one in Microsofts help file for Excel....
    It's a cool trick. Took me some time to figure out how it works.....

+ 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