+ Reply to Thread
Results 1 to 15 of 15

Vlookup with dynamic lookup range

  1. #1
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Vlookup with dynamic lookup range

    Hello all, any help gratefully received on the following please. I have a workbook with 2 worksheets. Sheet 2 uses a vlookup to search for values in Sheet 1. The problem is that for every one column the vlookup moves to the right in Sheet 2, the lookup range needs to change in Sheet 1 by 3 columns. I can't work out how to combine vlookup with index or match of offset to do this. In the attachment, cell D6 (almonds) in Sheet 2 needs to lookup with value for E3 (almonds) in sheet EB. The value for Almonds for each type of product is not in the same row in sheet EB
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Vlookup with dynamic lookup range

    I am having a tough time seeing what you want for an end result. Each group of three have the food item and 2 metrics.

    For Almonds in the first group (D:F) it's 42 and 16.8. In the second group (G:I for Almonds it doesn't exist. In the third group (J:L) it's 6 and 3. Which one of these values do you want, and do they go into columns D, E and F respectively on Sheet 2.

    Can you work out a few iterations for an item and show us what the desired result for that item would be and what cells on sheet EB they got that information from.

    Another question I have is that the titles on row 3, Sheet 2 don't seem to match anything on sheet EB.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    Firstly, thank you for spending the time and forgive me for anonymising one step too far. Here are the answers to your questions.
    1. In Sheet EB, Almonds has 2 values I'll need (i) 42 for % and (ii) 16.8 for grams. Not every group of 3 shaded columns (which represents one product) has Almonds.
    2. In Sheet EB, cell D7 should have a title "Kind Bars" which matches one of the Hlookup categories in Sheet 2
    3. In summary, in Sheet 2 for the first product (Kind Bars) Ill need the two values 42 and 16.8 from sheet EB. For the second product on Sheet 2, there are no values, for the 3rd product, the values would be 6 and 3.

    Hope that's clearer.
    Thanks

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Vlookup with dynamic lookup range

    On sheet 2, I see where you put the 42. Where would you want the 16.8?

  5. #5
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    Sheet 2 is used to populate a chart with % values. I want the 16.8 in a new Sheet 3 to create a second graph, using grams instead of %

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Vlookup with dynamic lookup range

    So two sheets: One sheet gets the 42, the other gets the 16.8. Correct?

    I am assuming that the titles are missing on sheet EB, row 7 but that the data are in the same order as on Sheet 2.

    I think I have a handle on this and should have something tomorrow.

  7. #7
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    Yes that's exactly right. I can send a more complete sheet if it would help you

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Vlookup with dynamic lookup range

    A more complete sheet would help. I'll take it

  9. #9
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    Here is new sheet
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    I played around with this some more but still can't get it working. On Sheet 1, I added a helper row at the top to return the address of the top left hand cell of the lookup array on sheet EnergyBars. I can get it to return a full file path including filename and cell address, but then this doesn't work inside the vlookup. There must be a simpler way of doing this and I would still be grateful for any help please. Thanks!
    Attached Files Attached Files

  11. #11
    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,208

    Re: Vlookup with dynamic lookup range

    In Sheet1

    in B4

    Please Login or Register  to view this content.

    in Sheet2

    in B4

    Please Login or Register  to view this content.

    In both Sheets, copy across and down
    Attached Files Attached Files

  12. #12
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Vlookup with dynamic lookup range

    Looks like John beat me to it.

  13. #13
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    thank you DFLAK and John. You were both v helpful. I'll now work through the formula so I understand the nested index and match functions. I hope this serves for anyone else with the same question

  14. #14
    Registered User
    Join Date
    06-12-2018
    Location
    yaounde
    MS-Off Ver
    2010
    Posts
    9

    Re: Vlookup with dynamic lookup range

    I've used the formula successfully on Sheets 1 and 2 now. Thank you again.

    One issue remains: when a particular manufacturer on sheet Energy Bars has more than one product (eg Loving Earth, in cells AN2 and BI2, Sheet 2 only picks up the leftmost occurence of the product when using the Index Match formula on Sheet 1 or Sheet 2.

    Please could you help me extend the formula so it checks TWO values on sheet Energy Bar? It needs to check in Row 2, and Row 5 so I get a unique product on Sheets 1 and 2.

    Thank you again.

  15. #15
    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,208

    Re: Vlookup with dynamic lookup range

    Not solving your request but changed the search to use wildcard

    in B4

    =IFERROR(INDEX(EnergyBars!$D$2:$CQ$100,MATCH("*" & $A4 &"*",INDEX(EnergyBars!$D$2:$CQ$100,0,MATCH(Sheet1!B$1,EnergyBars!$D$2:$CR$2,0)),0),MATCH(Sheet1!B$1,EnergyBars!$D$2:$CR$2,0)+1),"")


    =IFERROR(INDEX(EnergyBars!$D$2:$CQ$100,MATCH("*" & $A4 &"*",INDEX(EnergyBars!$D$2:$CQ$100,0,MATCH(Sheet1!B$1,EnergyBars!$D$2:$CR$2,0)),0),MATCH(Sheet1!B$1,EnergyBars!$D$2:$CR$2,0)+2),"")

    And "Loving Earth" was "Loving Earth " in "Energy Bars" (extra blank) so NO match was found.

    I have not thought about the duplicate but the simplest answer is to label them "Loving Earth_1" and "Loving Earth_2"

+ 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-20-2017, 04:27 PM
  2. [SOLVED] VLookup - function is not detecting lookup value on dynamic array
    By icordeiro in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-29-2016, 10:27 AM
  3. [SOLVED] VLOOKUP, gives #N/A error (if Range lookup=0) or wrong data (if Range lookup=empty)
    By Ebalinska in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 01-14-2016, 05:55 AM
  4. Dynamic or Variable Lookup array in INDEX, MATCH or VLOOKUP
    By kishor_c in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-16-2012, 09:46 AM
  5. using lookup and match in dynamic range
    By jrtaylor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-18-2011, 12:35 AM
  6. Lookup Against Dynamic Range Using VBA
    By dgo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-01-2009, 08:44 AM
  7. Lookup with dynamic range
    By Ola Sigurdh in forum Excel General
    Replies: 4
    Last Post: 08-08-2005, 11:05 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