+ Reply to Thread
Results 1 to 8 of 8

building a formula

  1. #1
    Registered User
    Join Date
    12-13-2006
    Posts
    12

    building a formula

    i need to build a formula that returns the value of the right most cell in a row that contains a value. for example, if i look at a row that looks like this:

    A B C D E F
    1 () () 1 0

    it should return the value in column E.

    anyone know how to do this? i am stuck

    TIA!

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

    =LOOKUP(2,1/(A1:F1>0),A1:F1)

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

    =LOOKUP(9.9999999E+307,1:1)

    where 1:1 represents the row the values are in.
    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.

  4. #4
    Registered User
    Join Date
    12-13-2006
    Posts
    12
    that would work if the final cell's value equals zero but the final cell's value can equal anything (and can even be repeated throughout a row. for example

    A B C D E F
    1 () () 2 0 1
    () () () 2 () ()
    () () 2 () () 0

    any ideas? first row should return 1, second row should return 2, third row should return 0.

    THANKS!

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by dianahatesboys
    that would work if the final cell's value equals zero but the final cell's value can equal anything (and can even be repeated throughout a row. for example

    A B C D E F
    1 () () 2 0 1
    () () () 2 () ()
    () () 2 () () 0

    any ideas? first row should return 1, second row should return 2, third row should return 0.

    THANKS!
    which formula are you talking about...

    Mine placed in a cell below those rows and copied down will extract the 1, 2, and 0 as required.

  6. #6
    Registered User
    Join Date
    12-13-2006
    Posts
    12
    Quote Originally Posted by NBVC
    which formula are you talking about...

    Mine placed in a cell below those rows and copied down will extract the 1, 2, and 0 as required.
    oh i am sorry i did not see your reply before i responded!

    thanks, yes this formula is exactly what i am looking for. i don't know if this is a stupid question but can you explain why/how it works? i'd like to understand why 9.9999999E+307 is relevant in particular.

    and how do i build a formula to return the column number that contains the rightmost value? in my previous example, it would return 6, 4, 6.

    THANK YOU AGAIN!

    ETA: never mind - i was able to figure out what i really needed. i wanted it to return a value from another cell based on the column the rightmost cell was in but i figured it out. THANKS AGAIN!
    Last edited by dianahatesboys; 11-28-2007 at 06:20 PM.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Apologies, I assumed that you wanted the last non-zero value, that's what my suggested formula above gives.

    According to "Excel specifications and limits" the largest value you can have in a cell is 9.99999999999999E+307 (NBVC used a shorter version). When you use LOOKUP with a lookup value, i.e. that large number, which is greater than any number in the lookup range, the last number is returned, which is what you need

    If you want the position of the last number you could just change LOOKUP in NBVC's suggestion to MATCH, i.e......

    =MATCH(9.9999999E+307,1:1)

    ....although if you want to return, say, the value in row 1 corresponding to the last numeric value in row 2 you don't need MATCH, just amend the LOOKUP formula like this:

    =LOOKUP(9.9999999E+307,2:2,$1:$1)
    Last edited by daddylonglegs; 11-28-2007 at 08:39 PM.

  8. #8
    Registered User
    Join Date
    12-13-2006
    Posts
    12
    thanks for taking the time to reply! your solutions and explanation was very helpful.

    as a follow-up, is there any way to manipulate this formula to return the next to last numerical value? in my previous example

    A B C D E F
    1 () () 2 0 1
    () () () 2 () ()
    () () 2 () () 0

    it would return 0, n/a, 2

    THANKS AGAIN!

+ 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