+ Reply to Thread
Results 1 to 32 of 32

Vlookup (but select range based on values)

  1. #1
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Vlookup (but select range based on values)

    Dear Friends,

    i have a excel file which i have to perform a complex vlookup in sheet1

    sheet 1 has 2000 rows and 9 coloumns, i need to vlookup (also match column) and fill the values in sheet2

    the problem is the values i am performing vlookup and match have multiple presence, but their intersection is only one value (which i want vlookup to return).

    i am attaching the file (have a look at both sheets).

    kindly help.

    regards
    atul
    Attached Files Attached Files

  2. #2
    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,205

    Re: Vlookup (but select range based on values)

    Try

    in B2

    =IFERROR(INDEX(Sheet1!$D$5:$I$86,MATCH(Sheet2!B$1,Sheet1!$C$5:$C$86,0),MATCH(Sheet2!$A2,Sheet1!$D$4:$I$4,0)),"")

    Copy across and down

    Unfortunately none of your sample (column A) match so I changed one reference to test it.

  3. #3
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    hey, this returns a black cell. and column A in sheet2 matches in 4 rows in Sheet1.

  4. #4
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Vlookup (but select range based on values)

    Hi learnall18,

    The problem you've got is that your data contains multiple data sets. You would be best cleaning it up and then the solution should be a fairly straightforward INDEX/MATCH formula.

    Regards,

    Snook

  5. #5
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup (but select range based on values)

    I could not find a simple solution to your search

    Therefore I created a database with a unique key for Item ID and Location with a macro
    Then, the vlookup() was simple as shown.

  6. #6
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thanks for reply snook, yes there are multiple data sets, but there is consistency so i feel this formula is achievable.

  7. #7
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    how can i do that??

  8. #8
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup (but select range based on values)

    Here is the file with the macro included...

  9. #9
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup (but select range based on values)

    It is not letting me load the file so I include the macro
    A tab under the name 19.05.2016 needs to be created

    Please Login or Register  to view this content.

  10. #10
    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,205

    Re: Vlookup (but select range based on values)

    I didn't realise the data was in multiple tables: it needs all locations down column A and corresponding "codes" across columns then the INDEX MATCH of the form I have will work with appropriate range changes.

    Sample file attached showing preferred format. Not All data has been reformatted - rows 301 onwards need to copied to columns as per other data.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thanks, but is it possible to achieve it using a formula?

  12. #12
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thanks john, can we use SETOFF and achieve the formula without formatting?

  13. #13
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup (but select range based on values)

    I am sending the workbook in version 2010 with the macro included and the reformatted data so the vlookup function can be applied

    The macro takes the input as is from sheet1 and renders the data in a table in sheet 19.05.2016 as mentioned before in post #9. create the tab with that name and run the macro. then vlookup your prices from that tab.
    Attached Files Attached Files
    Last edited by rcm; 05-24-2016 at 11:48 AM.

  14. #14
    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,205

    Re: Vlookup (but select range based on values)

    Data fully formatted.

    You will need VBA to do this normally (I just did copy/paste)
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thanks rcm, macro seems doing it, can u also help me with a link for basic macro tutorial? does this macro also work on google sheet? is it possible to achieve a formula to do this?

  16. #16
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thanks john! will try with vba..do u think its possible to achieve a formula to do this? if no, then will go with vba, as i am not good with vba i generally avoid it.

  17. #17
    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,205

    Re: Vlookup (but select range based on values)

    I think it would be very difficult to reformat using formulae: I don't know it would be done.

  18. #18
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup (but select range based on values)

    the macro below will organize the data in a matrix form. If you care to try it create a tab named "columns"
    regarding the post #15 I would look it up but googleing "VBA tutorial" can be a start

    Please Login or Register  to view this content.

  19. #19
    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,205

    Re: Vlookup (but select range based on values)

    Macro to reformat code

    Please Login or Register  to view this content.
    "Input" sheet to "OuPut" sheet.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thanks a lot john, this is doing the trick, however since there is inconsistency in input files. i tried converting my pdf from nitro and it gave me all tables in seperate sheets, now i tried index/match formula and used iferror function to include all sheets in search, but the formula is very very long, can you tell me how to make a formula which includes all sheets?. attaching new file. thanks inadvance
    Attached Files Attached Files

  21. #21
    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,205

    Re: Vlookup (but select range based on values)

    I don't think you can create a formula which looks at all sheets: hence the need of the (a) macro to convert (copy) all the data to one sheet.

    Such a formula would have (or have the ability) to look at all sheets ... IF(INDEX(Sheet! ........,IF(........))))): totally impractical in my view.

  22. #22
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    i just learned recording a macro, i dont know vba...but recording a macro seems easy....is it reliable ??

  23. #23
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    and i was browsing the forum, there is a trick by naming all sheet names as range and then do index/match, however i am unable to construct the right formula, can that named range work??

  24. #24
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup (but select range based on values)

    this is an alternative.
    1. create a tab named "Master"
    2. place it at the end
    3. run the macro
    4. Master should have the data from all pages in one tab

    Please Login or Register  to view this content.

  25. #25
    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,205

    Re: Vlookup (but select range based on values)

    Go with the macro solution provided by "rcm".

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

    Re: Vlookup (but select range based on values)

    ARRAY formula in B2 of Sheet2, then drag across.
    Please Login or Register  to view this content.
    ARRAY formula is used

    To enter ARRAY formula
    Paste the formula
    Press F2
    Press Ctrl+Shift+Enter keys together.
    formula will be covered with{} brackets.
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    HEYY kvsrinivasamurthy, thanks thanks thanks!!! wonderfully works!! your formula is a charm,.

    just one last thing. with this same file, i tried a wonderful PDF converter. smallpdf.com (work with pdf so perfectly, far better than nitro). this gave me the TABLES in separate sheets (unlike the sheet which i earlier posted which gave me all tables in single sheet. i want to use smallpdf.com as its flawless. so my input file is changed. kindly help with this formula. thanks a lot.
    Attached Files Attached Files
    Last edited by learnall18; 05-26-2016 at 02:19 AM.

  28. #28
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    also, thank you john and rcm for the effort!! :-) great full to you

  29. #29
    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,205

    Re: Vlookup (but select range based on values)

    Very impressed by kvsrinivasamurthy's formula: yet to "decipher" it!

    Thank you for the feedback and rep: much appreciated.

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

    Re: Vlookup (but select range based on values)

    For your new excel file with more number of worksheets.
    ARRAY formula in B2 of Sheet "Final", then drag across
    Please Login or Register  to view this content.
    Attached Files Attached Files

  31. #31
    Registered User
    Join Date
    05-18-2016
    Location
    india
    MS-Off Ver
    2007
    Posts
    30

    Re: Vlookup (but select range based on values)

    thank you. it works great :-)

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

    Re: Vlookup (but select range based on values)

    You are welcome.

+ 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] VLOOKUP with the ability to select named range based on a date in another cell
    By Webbers in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 04-22-2016, 02:00 PM
  2. Select range of data based on values in colum A
    By eddiej90 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-07-2016, 06:12 PM
  3. Replies: 1
    Last Post: 10-16-2014, 04:29 PM
  4. [SOLVED] How to Select Worksheet and Cell/range based on ComboBox Values
    By ckarlest in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2014, 10:54 AM
  5. [SOLVED] Select a range of rows based on start row and end row being values in two worksheet cells
    By xlnube in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2012, 08:41 PM
  6. Replies: 6
    Last Post: 09-04-2012, 10:35 AM
  7. [SOLVED] How to select a range based on values in 1 column
    By ForestRamsey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2005, 12: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