+ Reply to Thread
Results 1 to 5 of 5

Value of Second-to-Last Non-empty cell

  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Value of Second-to-Last Non-empty cell

    So what I am trying to do, is find the second to last filled cell in a row. The last value (which I also needed) can be found using this formula that I found:

    =LOOKUP(2,1/(D2:Z2<>""),D2:Z2)

    But I'm not sure how to use that to find the second to last value. I've done some googling but I can't seem to find any formulas that are independent of the values being a maximum or a minimum. My values will not necessarily be sequential, by that I mean they will not always increase or always decrease.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Value of Second-to-Last Non-empty cell

    Hi Scruffy,

    The following should return the value from the cell that is two cells to the left of the last value found in D2:Z2...

    =INDEX(D2:Z2,MATCH(9.99E+307,D2:Z2)-2)

    If you need the value from the cell that is one cell to the left, change the -2 to -1.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Value of Second-to-Last Non-empty cell

    Alternate version, works with numbers or text, always finds the penultimate value (unless there are fewer than two values populated)
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

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

  4. #4
    Registered User
    Join Date
    05-31-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Value of Second-to-Last Non-empty cell

    Quote Originally Posted by Paul View Post
    Hi Scruffy,

    The following should return the value from the cell that is two cells to the left of the last value found in D2:Z2...

    =INDEX(D2:Z2,MATCH(9.99E+307,D2:Z2)-2)

    If you need the value from the cell that is one cell to the left, change the -2 to -1.
    Thanks! This worked perfectly!

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

    Re: Value of Second-to-Last Non-empty cell

    If that works then your data is presumably numeric and without gaps, if so try also

    =LOOKUP(9.99E+307,E2:Z2,D2:Y2)
    Audere est facere

+ 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