+ Reply to Thread
Results 1 to 16 of 16

Loop, match and return values

  1. #1
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Loop, match and return values

    Hi all,

    Assume you hold your stock in several external warehouses. They obviously hold stocks for other companies too. Every day you receive stocklists from all of them. The aim is to run a report that would only include your stock. So, basically if you know what stock you hold in which warehouse, it would be looping through all stocklists, matching your product and delivering qty, warehouse ID and best before date to a separate sheet. Sounds simple, but I struggle to get this laid out on VB editor...

    Can someone please look at the attached dummy, where I have also replicated the desired result for you to understand what am I trying to achieve.

    Thanks for your priceless help.
    Attached Files Attached Files

  2. #2
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    Forgot to mention there are 4 warehouses we receive stocklists from. On a dummy it only shows 2. My bad...

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Loop, match and return values

    How about
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    Hi Fluff13 and thanks for response.

    I should have mentioned this at the beginning, that all stocklists are in completely different layout. I thought the solution will be very simple For loop, which I will be able to adapt (changing sheet names, ranges etc.). Apparently your code is beyond my comprehension, but works with dummy spreadsheet. I won't be able to adapt this code for original spreadsheet.

    Apologies for all.

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Loop, match and return values

    This works with the data you provided but not sure about the "actual" data:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Loop, match and return values

    Quote Originally Posted by ABSTRAKTUS View Post
    I should have mentioned this at the beginning, that all stocklists are in completely different layout.
    In that case you will need to supply a workbook showing your actual data layout, not a simplified version.

  7. #7
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    I shall describe the layout as it truly is. There are 4 sheets for stocklists named:
    1. ASHINGTON (product in col G, quantity in col M, best before in col P)
    2. OPTIMA (product in col A, quantity in col E, best before in col C)
    3. OAKLANDS (product in col P, quantity in col C, best before in col D)
    4. GILLINGHAM (product in col C, quantity in col H, best before in col L)

    I hope this will clarify a lot... Sorry again.

  8. #8
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    I have attached the workbook that code really needs to go on...
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Loop, match and return values

    As I do not have the time to "Mock-up" a sample workbook, you will need to do that.

  10. #10
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    Can't adapt either code...

  11. #11
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Loop, match and return values

    This became much more complex with differing data representations and columns. However, see the attached.

    WBD
    Attached Files Attached Files

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Loop, match and return values

    How about
    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    Speechless... Solved!

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Loop, match and return values

    Glad we could help & thanks for the feedback

  15. #15
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Loop, match and return values

    Hello again, just a quick advise I'm after. What if I want to add additional fields to 4 I already have, what part of code do I change?

    Thanks again!

  16. #16
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Loop, match and return values

    You would need to change the select case statements
    Please Login or Register  to view this content.
    This would add the description in Col B (ie column 2)
    And then Change the value in red here
    Please Login or Register  to view this content.
    To reflect the number of columns in the output.
    Finally add new rows here as shown in red
    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. [SOLVED] Input a range of values into a cell and return the values for each loop
    By cavalieregiuseppe in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-10-2018, 11:31 PM
  2. Return Multiple Match Values in Excel Using INDEX-MATCH
    By chris1089 in forum Excel General
    Replies: 10
    Last Post: 06-15-2017, 09:25 AM
  3. [SOLVED] Vlookup/index/match to return all values that match
    By Asil01 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-09-2014, 12:49 PM
  4. Using Index/Match to return multiple values for one match
    By superboy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-10-2014, 06:21 PM
  5. multiple match, match loop?? vba, return many rows
    By pavlos in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-16-2014, 11:44 AM
  6. Replies: 2
    Last Post: 11-12-2012, 06:26 AM
  7. Replies: 5
    Last Post: 10-11-2008, 04:01 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