+ Reply to Thread
Results 1 to 3 of 3

Return a value in a reference row based on the last occurence of a value in an array

  1. #1
    Registered User
    Join Date
    11-24-2009
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    8

    Return a value in a reference row based on the last occurence of a value in an array

    Ok. This might be better illustrated than explained....

    I have a header row (row A) numbered as such (they are week numbers from 2010/2011):
    B1: 51
    C1: 52
    D1: 1
    E1: 2

    Then, I have part numbers in the first column like such:
    A2: 101000
    A3: 201000
    A4: 301000
    A5: 401000

    Then, I have amounts sold next to each item for the corresponding week# Like such:

    B2: (corresponds to sales for 101000) 0 (wk51) C2: 0 (wk52) D2: 1 (wk1) E2: 1 (wk2)
    B3:5 C3:7 D3:6 E3:0
    B4:0 C4:0 D4:0 E4:0
    B5:1 C5:1 D5:1 E5:1

    I wish to write a function to return the following result:

    FOR EACH PART: LOCATE THE LAST CELL IN THE ROW CONTAINING A VALUE >0 AND RETURN THE REFERENCE VALUE FROM THE HEADER ROW (ROW A, WEEK #)

    This tells me when was the last time we sold this item. This grid is massive with 80,000 records and 26 weeks.

    The result if I wrote the correct formula (struggling) would be as follows: (if I were to put the results in column F for each item)

    F1: "Last movement wk#"
    F2: 2 (last cell containing a value >0 is E2 (contains "1") so would return value 2 (week number, from cell E1).
    F3: 1
    F4: 0 (none sold, so zero returned or error value such as N/A#)
    F5: 2

    Any help would be greatly appreciated. I am 'familiar' with functions such as array formulae (in braces), offset, max, match, and lookup. I cannot, however, seem to put anything together to get me the right answer!

    Thanks sooooo much. This is for work, due tomorrow, and I am out of ideas aside from pouring the whole thing into access.
    Last edited by zestygirl; 02-17-2011 at 03:54 PM.

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

    Re: Return a value in a reference row based on the last occurence of a value in an ar

    IN F2:

    =LOOKUP(2,1/($B2:$E2>0),$B$1:$E$1)

    copied down
    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
    Registered User
    Join Date
    11-24-2009
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Return a value in a reference row based on the last occurence of a value in an ar

    Excellent! I had written something similar, but had failed to make the ranges absolute.

    Thanks so much!

    And from Mississauga. A little help from my friend (I'm in sauga too).

+ 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