+ Reply to Thread
Results 1 to 11 of 11

Formula needed to return multiple results based on one reference

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Unhappy Formula needed to return multiple results based on one reference

    Must say that I've browsed this forum for quite some time and loved it so much I registered in the event I could help somebody out (hasn't happened yet) or my fear...I needed help.

    Well like many posts have started out...I've searched, read, searched, read, and still cannot find something close enough to my need so here goes my first post.

    The attachment is setup as such:

    Sheet "Main" has the following:

    ITEMS in cells A2:A16
    ORDER #'s in cells B2:B16
    TOTAL QTY in cells C2:C16

    Sheet "Data" has the raw reporting sales order data, hypothetically extracted from our company database.
    Items in column A, Order # in column B for items, and qty per item/order# in column C.

    On the Main sheet I have used the "sumif" formula to calculate the total qty on order for the referenced item, no issues. How in the world can I use VLOOKUP, or something similar to report back (Column B is my intention) each individual ORDER #?

    So if I have Toys on order #'s 1,2, and 3...I would like to see it show "1, 2, 3"

    Please help!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Formula needed to return multiple results based on one reference

    Hi

    One way is to use a User Defined Function (UDF).

    Put the code below into a general module in the relevant workbook.

    Please Login or Register  to view this content.
    Then using your example file, enter =myfunc(DATA!$A$2:$A$61,MAIN!A2) in Main!B2 and copy down to B16.

    HTH

    rylo

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Formula needed to return multiple results based on one reference

    Here is a UDF and a spreadsheet with a demo on how to set it up.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Re: Formula needed to return multiple results based on one reference

    Thank you for the feedback guys - working on this today.

  5. #5
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Re: Formula needed to return multiple results based on one reference

    This is working, but I have a quick question. My actual sheet I'm working with has spaces between items, so as I copy the formula down it returns #VALUE! when the cell in column A is blank. Is there some type of conditional formatting I can use to "hide" this result? In the past I've used White font w/ no fill when wanting to make zeros disappear, but I don't know how to do it in this case.

  6. #6
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Re: Formula needed to return multiple results based on one reference

    Posed the question way too soon, sorry - forgot about More Rules/New Rules.

  7. #7
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Re: Formula needed to return multiple results based on one reference

    Quote Originally Posted by alansidman View Post
    Here is a UDF and a spreadsheet with a demo on how to set it up.
    So I am having decent success understanding this, but I'm running into one small issue. I've pasted the code into a module and used the formula. However after I fill the formula down the column it does not formulate...UNTIL I go to my Table Array and make a small edit. This edit could be as simple as changing a "Q" to a "F". Once I make that change everything works. Is there something I'm missing?

  8. #8
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Re: Formula needed to return multiple results based on one reference

    I guess it seems like I'm not "starting" the VBA or something...

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Formula needed to return multiple results based on one reference

    Thanks for the PM. I just tested on my machine and did not have an issue. I have the code posted in a module. Do you have calculations set to automatic or manual? Just guessing at what may be the issue. If you want someone to examine your spreadsheet and code, upload a copy.

  10. #10
    Registered User
    Join Date
    11-08-2012
    Location
    United States
    MS-Off Ver
    2007
    Posts
    39

    Re: Formula needed to return multiple results based on one reference

    Calculation method checked, tried Manual/calculating and Automatic....Attached I believe should work as an example
    Attached Files Attached Files

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Formula needed to return multiple results based on one reference

    I cannot determine what is the cause of your issues. As an alternative, I have another multi vlookup that you can try.

    Please Login or Register  to view this content.
    Look at this thread for an explanation if you have difficulty understanding the code.
    http://www.mrexcel.com/forum/showthr...ight=muvlookup

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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