+ Reply to Thread
Results 1 to 13 of 13

Selective Vlookup

  1. #1
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Selective Vlookup

    What I am currently doing in this example is in N3 give me the Symbol value in "K" of the Corn contract with the largest Open Interest. In this case it would be "ZCK17". As you can see i am setting the max to D2:D9. This sheet works just fine until i get a new sheet with more data and heaven forbid the corn is not in the right spot.

    Ideally what i want is for the program to search for all "CORN" and give the max value so i can say search for the highest corn value in A1:I28.

    Thanks for your help.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Selective Vlookup

    OK, this is the lazy way with full column references:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    committed with Ctrl-Shift-Enter rather than just Enter.

    Ideally, you need to use a static range which will be greater than the number of rows of data. Or, better, create Dynamic Named Ranges for columns A, B and C. Or, possibly even better, convert your data into a Structured Table and then use Table references for the columns of data. The last would be my preferred option.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Selective Vlookup

    in N3

    =INDEX($K$2:$K$28,MATCH(MAX(--($B$2:$B$28=M3)*($D$2:$D$28)),$D$2:$D$28,0))

    Enter with Ctrl+Shift+Enter...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.

  4. #4
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Selective Vlookup

    Is there a way to do this without arrays? I will be handing this over to someone and they will not know how to do that.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Selective Vlookup

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



    Create Dynamic Named Ranges in Name Manager:

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


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


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

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Selective Vlookup

    If I knew a way to do it without arrays, I would have suggested it.

    Maybe someone else can offer an alternative.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Selective Vlookup

    Try

    =VLOOKUP(MAX(OFFSET($B$1,MATCH($M3,B:B,0),2,COUNTIF(B:B,M3))),$D$2:$K$1000,8,0)

    Assumes column B is sorted as per your file.


    OR

    =INDEX($A$2:$A$1000,MATCH(MAX(OFFSET($B$1,MATCH($M3,$B:$B,0),2,COUNTIF($B:$B,$M3))),$D$2:$D$1000,0))


    From Column A
    Last edited by JohnTopley; 02-22-2017 at 06:05 PM.

  8. #8
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Selective Vlookup

    JOHN !!!! HOLY S...... this is great. i have NO idea of why it works... HA.... but thank you!!!!!

  9. #9
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Selective Vlookup

    John- Actually i found a problem. I have attached my real sheet and it works great for many of the items but for some reason its getting it wrong on a few. See in Col P where it says bad. For some reason its not finding Hard Red Wheat.

    Also see how High Grade Copper is showing the correct value for Crude... but then Crude is showing Crude correctly but its not the right month.....
    Attached Files Attached Files

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Selective Vlookup

    Try this non-array formula:

    Please Login or Register  to view this content.
    Drag down.
    Quang PT

  11. #11
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Selective Vlookup

    Just change formula as,
    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Selective Vlookup

    With VLOOKUP change: you added an extra row in the file (?)
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Selective Vlookup

    Thanks everyone. this is just amazing....

+ 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. a formula that is selective
    By treatedwood in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-26-2014, 04:05 AM
  2. [SOLVED] Combination of VLOOKUP and VBA to achieve selective copying to next sheet
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2013, 02:56 PM
  3. [SOLVED] Selective SUM
    By bryan444 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-11-2013, 01:24 PM
  4. Replies: 5
    Last Post: 12-11-2012, 05:04 AM
  5. Selective Value Lists
    By Tesla in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2012, 01:24 AM
  6. [SOLVED] Selective average
    By BPG in forum Excel General
    Replies: 8
    Last Post: 04-20-2012, 03:56 PM
  7. Selective Counting
    By ZackG in forum Excel General
    Replies: 4
    Last Post: 03-29-2011, 10:08 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