+ Reply to Thread
Results 1 to 7 of 7

VLOOKUP - returning value with last entry in a table

  1. #1
    Registered User
    Join Date
    03-13-2012
    Location
    Deventer, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    64

    VLOOKUP - returning value with last entry in a table

    Hi there,
    I have a table with dates and multiple values with these dates.

    My VLOOKUP formula returns the 'first hit' which goes with the entry date. I'd like a formula which returns me the last value instead.

    the problem is illustrated in the attached sheet.

    Thanks,
    Niels
    Attached Files Attached Files

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VLOOKUP - returning value with last entry in a table

    In your formula, change the 0 to 1
    Please Login or Register  to view this content.
    Last edited by gmr4evr1; 11-14-2015 at 05:21 PM. Reason: Added revised formula
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: VLOOKUP - returning value with last entry in a table

    Tom, that doesnt work Add another 1/1 at the end, it does not get picked up.

    Niel if you are OK with a helper column (which you can hide), try this...
    A
    B
    C
    D
    E
    F
    1
    1-Jan
    6
    42005.01
    1-Jan
    2
    2-Jan
    7
    42006.01
    9
    <-- I'd like the formula to return 9 instead of 6
    3
    3-Jan
    8
    42007.01
    44
    4
    1-Jan
    9
    42005.02
    5
    2-Jan
    10
    42006.02
    6
    3-Jan
    11
    42007.02
    7
    1-Jan
    1
    42005.03
    8
    2-Jan
    2
    42006.03
    9
    3-Jan
    3
    42007.03
    10
    1-Jan
    44
    42005.04
    11
    2-Jan
    55
    42006.04
    12
    3-Jan
    6
    42007.04

    Column C is the helper with this, copied down...
    =A1+COUNTIF($A$1:A1,A1)/100

    Then to pull out your value, use this ARRAY formula...
    D3=INDEX($B$1:$B$12,MATCH(MAX(IF(INT($C$1:$C$12)=$D$1,$C$1:$C$12,0)),$C$1:$C$12,0))
    ...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. Press F2 on that cell and try again.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: VLOOKUP - returning value with last entry in a table

    Quote Originally Posted by gmr4evr1 View Post
    In your formula, change the 0 to 1
    =VLOOKUP(D1,A:B,2,1)
    If you get the correct result with that formula it's just dumb luck!

    Look at this data:

    Data Range
    A
    B
    C
    D
    1
    1-Jan
    10
    1-Jan
    2
    2-Jan
    7
    10
    3
    1-Jan
    8
    4
    1-Jan
    2
    5
    1-Jan
    10
    6
    3-Jan
    11
    7
    1-Jan
    1
    8
    ------
    ------
    ------
    ------


    The formula returns an incorrect result.

    Use this formula:

    =LOOKUP(2,1/(A1:A7=D1),B1:B7)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VLOOKUP - returning value with last entry in a table

    Wow, I guess it was dumb luck. When I tested it before posting, it worked perfectly. But I only tested it with 3-Jan. Had I tested it with the other dates as well, I would have seen that it did not work. Thanks for having my back guys. My apologies to OP.

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

    Re: VLOOKUP - returning value with last entry in a table

    You're welcome!

  7. #7
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,294

    Re: VLOOKUP - returning value with last entry in a table

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

+ 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: 6
    Last Post: 12-10-2013, 05:34 PM
  2. Why is my Vlookup returning N/A when looking up from a pivot table
    By Schoeii in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-27-2013, 09:28 PM
  3. Macro to insert new VLOOKUP table entry
    By eb710 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2013, 10:46 AM
  4. [SOLVED] VLOOKUP returning multiple answers from table
    By Cyclewench in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-06-2013, 03:18 AM
  5. [SOLVED] Certain rows of a VLOOKUP table are returning as N/A. but why?
    By Solidstan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-26-2013, 06:46 PM
  6. Returning an entry from a table based on the current date
    By jshaw82 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-14-2012, 12:37 PM
  7. Replies: 2
    Last Post: 06-27-2011, 09:11 PM
  8. Replies: 6
    Last Post: 06-19-2008, 01:41 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