+ Reply to Thread
Results 1 to 8 of 8

Last Numeric Value in Filtered Table

  1. #1
    Registered User
    Join Date
    10-13-2011
    Location
    Bellefonte, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Last Numeric Value in Filtered Table

    I have a table and one of the columns will have a lot of blank cells with some numeric values entered into it. I need to pull the last numeric value that is entered in the column.
    The table will be filtered from time to time and I want the formula to update the last numeric value accordingly. In other words, if the table is filtered, I want the formula to only pull the last numeric value based upon the VISIBLE cells and to ignore the hidden cells that are filtered out.

    The following equation will show the last numeric value in Column L:

    =INDEX(L:L,MATCH(9.9999E+306,L:L))

    However, when the table is filtered that equation stills shows the absolute last value, even if that cell is hidden. Is there a way to get the same result from the previous formula but to ignore hidden cells?

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last Numeric Value in Filtered Table

    I don't believe you can test for if a cell is hidden without vba but you should be able to use what it is filtered by if that is constant?

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Last Numeric Value in Filtered Table

    this seems to work
    =INDEX($A$1:$A$30,LOOKUP(2,1/INDEX((SUBTOTAL(104,OFFSET(A2:A30,ROW(A2:A30)-ROW($A$2),0,1))*ROW(A2:A30))>0,0),ROW(A2:A30)))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Last Numeric Value in Filtered Table

    Great formula, Martin!
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Registered User
    Join Date
    10-13-2011
    Location
    Bellefonte, PA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Last Numeric Value in Filtered Table

    Martin, this formula works great. I'm not gonna lie, I'm pretty impressed. I can't figure out why it works though. Would you mind giving me a brief explanation as to the methodology? The whole [array]*[array] thing is messing with my brain.

    Thanks for the help.

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Last Numeric Value in Filtered Table

    no idea! i just adapted it from some formula snippets i had and kept trying different things untill it worked

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Last Numeric Value in Filtered Table

    This may be a little simpler but must be array entered

    =LOOKUP(9E+307,IF(SUBTOTAL(102,OFFSET(L2:L30,ROW(L2:L30)-ROW($L$2),0,1)),L2:L30,""))

    OFFSET(L2:L30,ROW(L2:L30)-ROW($L$2),0,1)) creates an array of single cell ranges for each cell of L2:L30
    SUBTOTAL(102,) returns 1 (coercible to TRUE) for each numeric cell that is visible thus the rest of the formula is only:
    LOOKUP(9E307,IF(true/false array,L2:L30,""))

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,697

    Re: Last Numeric Value in Filtered Table

    This formula will give you the last visible numeric value in L2:L100 (assuming hidden rows through filtering)

    =LOOKUP(2,1/SUBTOTAL(2,OFFSET(L2,ROW(L2:L100)-ROW(L2),0)),L2:L100)

    doesn't need array entry

    The SUBTOTAL/OFFSET part returns a 1/0 value for every row, only 1 if it's visible and a number [2 in SUBTOTAL only counts numbers]

    When you divide that array by 1 you therefore get 1s and errors. If you lookup 2 in that array it will always match with the last 1, and then LOOKUP gives you the corresponding value in L2:L100, hence giving you the last visible number

    You can use the same approach for last number (not considering the filter), i.e.

    =LOOKUP(9.99E+307,L2:L100)
    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)

Similar Threads

  1. Replies: 3
    Last Post: 11-04-2013, 07:50 PM
  2. Replies: 8
    Last Post: 04-04-2013, 05:13 PM
  3. Replies: 1
    Last Post: 11-01-2012, 12:28 AM
  4. Replies: 2
    Last Post: 06-16-2011, 06:53 PM
  5. Creating a filtered table from a source table in another sheet
    By penfold in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-12-2008, 07:44 AM

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