+ Reply to Thread
Results 1 to 12 of 12

Looking up last 5 values

  1. #1
    Registered User
    Join Date
    05-23-2017
    Location
    Omaha, NE
    MS-Off Ver
    2003
    Posts
    4

    Looking up last 5 values

    This is probably a stupid question but here it goes.... I want to find the last 5 values (non blank cells) that are set across a single row with 20 columns. And as I add more data it needs to continue to show the latest last 5 values.
    I have the formula (below) to locate the last value in the set but for some reason I've gone brain dead on how to retrieve the last 4 behind it

    Here's an example of what I got in the row thus far and what I'm looking for. "BC"= a blank cell
    55 54 BC 63 53 BC BC 55 54 BC 53 BC 57 59
    I used this generic formula =LOOKUP(2,1/(A2:T2<>""),A2:T2) to find the last value 59. I just can't figure out how to retrieve the other last 4 #'s (57,53,54,55) and so on as the list grows. And Yes, there will continue to be blank cells mixed in between the numbers.

    I would greatly appreciate any assistance that is given! THANK YOU in advance!

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Looking up last 5 values

    you can use LARGE as array formula

  3. #3
    Registered User
    Join Date
    05-23-2017
    Location
    Munich
    MS-Off Ver
    xl2010, xl2013, xl2016
    Posts
    5

    Re: Looking up last 5 values

    Hi,

    since you only have xl2003 I would use =INDEX($2:$2,Large(column($A$2:$T$2)*($A$2:$T$2<>""),Row(1:1)))
    Hit [Ctrl]+[Shift]+[Enter] to enter it as an array function.

    Michael

  4. #4
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Looking up last 5 values

    Assume you have A1:N1 with numbers and blank cells

    Try

    P1
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Drag towards the cell

    Check the attached file.
    Attached Files Attached Files
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,127

    Re: Looking up last 5 values

    Taxcel rose:

    =INDEX($2:$2,Large(column($A$2:$T$2)*($A$2:$T$2<>""),Row(1:1)))

    You'll need to edit this. It doesn't take whole row references either....
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  6. #6
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Looking up last 5 values

    Hi

    =INDEX($A$1:$U$1;LARGE(IF(NOT(ISBLANK($A$1:$U$1));COLUMN($A$1:$U$1);"");ROWS($A$4:A4)))

    Range is A1:U1
    if your data will go longer you should change the range
    Attached Files Attached Files
    Appreciate the help? CLICK *

  7. #7
    Registered User
    Join Date
    05-23-2017
    Location
    Munich
    MS-Off Ver
    xl2010, xl2013, xl2016
    Posts
    5

    Re: Looking up last 5 values

    Quote Originally Posted by Glenn Kennedy View Post
    =INDEX($2:$2,Large(column($A$2:$T$2)*($A$2:$T$2<>""),Row(1:1)))
    You'll need to edit this. It doesn't take whole row references either....
    Hm, I can't see any disadvantages due to referencing the whole row. There is no calculation based on this range within INDEX.

    Michael
    Last edited by taxcel rose; 05-26-2017 at 04:24 AM. Reason: TYPO

  8. #8
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Looking up last 5 values

    Here is another solution.

    Its an array formula as previous one but here you do not have to change range as new data added

    =INDEX($1:$1;LARGE(IF(ISBLANK(OFFSET($A$1;0;0;1;LOOKUP(999999;$1:$1;COLUMN($1:$1))));"";TRANSPOSE(ROW(INDIRECT("1:"&LOOKUP(999999;$1:$1;COLUMN($1:$1))))));ROWS($D$4:D4)))

    This one works only in numbers
    Last edited by AZ-XL; 05-26-2017 at 04:40 AM.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,127

    Re: Looking up last 5 values

    INDEX($1:1... a whole row reference. not with Excel 2003....

  10. #10
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Looking up last 5 values

    Did you checked post #4 ???

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Looking up last 5 values

    Try this:
    Enter array formula in P1 and copy across to N1 and then down

    **Must be entered with Ctrl+Shift+Enter key combination.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    for those who use Excel 2010 version or higher may use this regular formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    R
    S
    T
    U
    1
    55
    54
    63
    53
    55
    54
    53
    57
    59
    55
    54
    53
    57
    59
    2
    12
    47
    48
    11
    8
    15
    21
    48
    11
    8
    15
    21
    3
    17
    45
    17
    19
    24
    49
    32
    32
    89
    77
    74
    32
    11
    12
    77
    74
    32
    11
    12
    4
    5
    4
    3
    2
    1
    5
    4
    3
    2
    1
    Sheet: Sheet1
    Last edited by AlKey; 05-26-2017 at 10:47 AM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  12. #12
    Registered User
    Join Date
    05-23-2017
    Location
    Omaha, NE
    MS-Off Ver
    2003
    Posts
    4

    Re: Looking up last 5 values

    Thanks everyone for the replies and assistance!!! AlKey's formula seemed to work the best for what I need
    But again I thank you all for your help!!!!

    Have a Happy Memorial Day Weekend!

+ 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. [SOLVED] VBA Code replace old values to new values depends upon column values
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2015, 08:19 AM
  2. [SOLVED] VBA code to look up a list of values based on entered values and return all values.
    By dnwadams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2015, 10:14 PM
  3. [SOLVED] Extract values (row values and column values) with formula
    By bjnockle in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 08-17-2014, 10:13 AM
  4. [SOLVED] vba to Replace Old values by new values depends upon cell values in AC:AC col
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2014, 08:15 AM
  5. Replies: 0
    Last Post: 10-12-2012, 01:08 PM
  6. [SOLVED] How to lookup values same row values different column values
    By kgonzalbo in forum Excel General
    Replies: 5
    Last Post: 05-22-2011, 01:49 AM
  7. assigning date entries to week values and month values to sum column C-N values C-
    By the accountant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2010, 09:52 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