Results 1 to 8 of 8

Thread: Return the penultimate (second to last) non-blank value in column

  1. #1

    Return the penultimate (second to last) non-blank value in column



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi All,

    I am using Excel 2007 for Windows.

    I have a table that consists of many columns and expanding rows; for this reason, I have referenced the table as a dynamic named range called “Data”. “Data” can contain duplicate values in both columns and rows. I have numeric labels in row 3, spanning the width of my table; “Data” starts in column “G”, row 4. Column “A” contains sequential numeric values (references) that can be used as relative row numbers for my table. The cells within the table are populated with a formula that returns either a numeric value or empty text (“”) showing a blank cell. Zero is a valid numeric value in the table.

    Scenario:
    Find the penultimate (second to last) non-blank numeric value in a column within “Data”, and return to a cell. Please use the named range “Data” to create formula.


    Sample Layout of table "Data":
    Book6.xlsx attached


    Expected Results:
    Looking for penultimate value in column “V” in table –
    Found in column “V”, row 14; return value = 0

    Looking for penultimate value in column “AA” in table –
    Found in column “AA”, row 11; return value = 4

    Looking for penultimate value in column “AB” in table –
    Found in column “AB”, row 4; return value = 0

    Looking for penultimate value in column “AC” in table –
    Found in column “AC”, no cell with value; return value = nothing, empty text (“”)

    Looking for penultimate value in column “AD” in table –
    Found in column “AD”, no cell with value; return value = nothing, empty text (“”)

    Hope you can help.

    Thanks,
    Sam
    Attached Files Attached Files

  2. #2
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,429
    Articles
    0
    Excel Version
    Excel 2016
    Assuming you enter the column of interest in, say AG2 (e.g. 16 for column "V"), then try:

    =INDEX(INDEX($G$4:$AD$18,0,AG2),LARGE(IF(INDEX($G$4:$AD$18,0,AG2)<>"",ROW($G$4:$AD$18)-ROW($G$4)+1),2))

    confirmed with CTRL+SHIFT+ENTER not just ENTER.


  3. #3
    Thank you very much for your help and time. The formula works great! Brilliant!

    Sam

  4. #4
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,429
    Articles
    0
    Excel Version
    Excel 2016
    You're welcome.

    Note: You should surround with IFERROR() for when there is no "next number"

    =IFERROR(INDEX(INDEX($G$4:$AD$18,0,AG2),LARGE(IF(INDEX($G$4:$AD$18,0,AG2)=AH2,ROW($G$4:$AD$18)-ROW($G$4)+1),1)),"")

    confirmed with CTRL+SHIFT+ENTER not just ENTER.


  5. #5
    Will do; thank you,

    Quote Originally Posted by NBVC View Post
    You're welcome.

    Note: You should surround with IFERROR() for when there is no "next number"

    =IFERROR(INDEX(INDEX($G$4:$AD$18,0,AG2),LARGE(IF(INDEX($G$4:$AD$18,0,AG2)=AH2,ROW($G$4:$AD$18)-ROW($G$4)+1),1)),"")

    confirmed with CTRL+SHIFT+ENTER not just ENTER.
    Sam

  6. #6
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,429
    Articles
    0
    Excel Version
    Excel 2016
    I also commented on your other recent query, fyi. Let me know how that works too.


  7. #7
    Just to say: yesterday -Thurs 8 May, updated Thread "Return the last values below / after a Specific Value".

    Quote Originally Posted by NBVC View Post
    I also commented on your other recent query, fyi. Let me know how that works too.
    Thank you,
    Sam

  8. #8
    This looks like exactly what I'm after. Is it possible to tweak this to handle cells containing #N/A values? ie. if you replace the blank cells in the spreadsheet with =NA() this doesn't seem to work.

    Any ideas would be much appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •