+ Reply to Thread
Results 1 to 8 of 8

Upward and Left Lookup

  1. #1
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Upward and Left Lookup

    Hi,

    I have text in columns A, B and C. I am trying to create a formula in column D that will, for each item in C, return the first item in column B that is on the same row or on a row above it.

    For example, consider C11. In D11 I would like a formula to return the first text it encounters when looking up column B from B11 to B1.

    Can someone please suggest a solution.

    Thanks!

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Upward and Left Lookup

    Won't that always be the first value in B? Can you give some examples?

  3. #3
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Re: Upward and Left Lookup

    Hi Bob,

    Sorry that my post wasn't clear.

    For example, cells B6:B11 are blank but "Hello" is in B4 and "Goodbye" in B5. The formula in D11 would look up column B from B11 and return the first text it encounters, in this case "Goodbye".

    Thanks,

    Andrew

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Upward and Left Lookup

    I can do this, but only with a helper column.

    Assuming that your data starts in row 2, then in E2 put the fomula =IF(B2="","",ROW())

    Now in cell D2 you can put the formula =IF(C2<>"",OFFSET($B$1,MAX(INDIRECT("E2:E"&ROW()))-1,0),"")

    Copy the formulas in D2 and E2 down your sheet and see how it looks.
    Last edited by Andrew-R; 08-11-2011 at 04:49 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Upward and Left Lookup

    try this array formula in D11 and confirm throgh Ctrl+Shift+Enter

    =INDEX(B:B,LARGE(IF(LEN(C11)>0,IF(ISTEXT($B$1:INDIRECT("B"&ROW(C11))),ROW($B$1:INDIRECT("B"&ROW(C11))))),1))

    and copy down

    or use following in D11 not to show error or zero

    =IFERROR(INDEX(B:B,LARGE(IF(LEN(C11)>0,IF(ISTEXT($B$1:INDIRECT("B"&ROW(C11))),ROW($B$1:INDIRECT("B"&ROW(C11)))),""),1)),"")
    Last edited by Azam Ali; 08-11-2011 at 05:18 AM.
    Azam
    If you want to say Thank you to a member, click the reputation icon (Star) in the left bottom of the post.
    For prompt answer, be descriptive, concise, short, direct, and to-the-point.

  6. #6
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Re: Upward and Left Lookup

    Perfect, thanks very much

  7. #7
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Upward and Left Lookup

    If your problem is solved, mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes.

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

    Re: Upward and Left Lookup

    Why not simply ?

    Please Login or Register  to view this content.
    The above is non-volatile, non-array and uses Binary Search (fast).
    The approach is flawed if the strings in Column B exceed 255 chars in length
    (would require adaptation)

    FWIW, re: below:

    Please Login or Register  to view this content.
    there's no need for INDIRECT, relative references suffice surely ?

+ 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