+ Reply to Thread
Results 1 to 7 of 7

Grabbing last data

  1. #1
    Registered User
    Join Date
    06-28-2016
    Location
    Sea
    MS-Off Ver
    2013
    Posts
    12

    Grabbing last data

    Hello,
    I am looking for a function tool to grab the last value of a column even if there are empty cells or not as well as the second to last cell. I have tried INDEX, it did it except the empty cells it did not like. I then used LOOKUP but it then could not give me second to last cell by trying the "-1" at the end.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Grabbing last data

    Assuming a range of only F1:F16, this array formula can be used:

    =INDEX($F$1:$F$16, LARGE(IF($F$1:$F$16>0,ROW($F$1:$F$16), 0), 1))
    =INDEX($F$1:$F$16, LARGE(IF($F$1:$F$16>0,ROW($F$1:$F$16), 0), 2))


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Grabbing last data

    What type of data is it? Is it text? Numbers? Could be both? Something else?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    06-28-2016
    Location
    Sea
    MS-Off Ver
    2013
    Posts
    12

    Re: Grabbing last data

    Thanks JBeaucaire,
    Had to make some changes instead of the 1 and 2 at the end, 2 and 3 I had to use. However, after testing it, if there are empty cells close to the end, it does not like it and outputs empty values even if the empty cell is not second to last or the last one.

    Tony, the data is just numerical ones. No text.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Grabbing last data

    Quote Originally Posted by vlad n View Post
    Tony, the data is just numerical ones. No text.
    Try these...

    Data Range
    A
    B
    C
    D
    1
    36
    Last
    2nd Last
    2
    67
    69
    74
    3
    24
    4
    9
    5
    6
    98
    7
    90
    8
    24
    9
    2
    10
    33
    11
    74
    12
    ------
    ------
    ------
    ------
    13
    14
    15
    69


    This formula entered in C2:

    =LOOKUP(1E100,A1:A15)

    This array formula** entered in D2:

    =INDEX(A:A,LARGE(IF(ISNUMBER(A1:A15),ROW(A1:A15)),2))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  6. #6
    Registered User
    Join Date
    06-28-2016
    Location
    Sea
    MS-Off Ver
    2013
    Posts
    12

    Re: Grabbing last data

    Tony, that is exactly what I needed. It works in all cases I threw at it. Thank you for your help.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Grabbing last data

    You're welcome. Thanks for the feedback!

+ 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: 2
    Last Post: 01-27-2015, 12:10 PM
  2. Grabbing Web Query Data
    By supdawg1985 in forum Excel General
    Replies: 1
    Last Post: 04-01-2014, 03:44 PM
  3. Grabbing data from a website
    By Consty1 in forum Excel General
    Replies: 3
    Last Post: 06-17-2013, 02:21 PM
  4. Excel 2007 : Grabbing Data from Table A to B
    By OrangeBoy in forum Excel General
    Replies: 0
    Last Post: 10-10-2011, 10:42 PM
  5. Grabbing Data VBA
    By lienlee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2010, 01:48 PM
  6. Grabbing website data using GET
    By stereosound in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2009, 11:01 AM
  7. Grabbing Data from another File
    By Thriller in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2005, 02:05 PM

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