+ Reply to Thread
Results 1 to 9 of 9

Lookup and concatenate all matching entries in closed workbook

  1. #1
    Registered User
    Join Date
    04-12-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    67

    Lookup and concatenate all matching entries in closed workbook

    Hi,

    As per title I'm struggling to make this lookup. In fact, I'm not even sure of the best approach (array formula? UDF?).

    I need to basically Vlookup all matching entries in a closed workbook and concatenate them with commas between. Eg:

    Please Login or Register  to view this content.
    Function(3) returns Fred, Sarah, Robert
    Function(4) returns Rachel, Lilly
    Function(5) returns Yyvonne

    Any help would be gratefully received.

    Thanks,

    Chinchin

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Lookup and concatenate all matching entries in closed workbook

    Chinchin,

    This is a common request. Mike Rickson published a great UDF for this, see this post for details:

    http://www.excelforum.com/2593269-post9.html

    Hope that helps,
    ~tigeravatar

    EDIT: I originally stated that Mike Erickson published the UDF
    Last edited by tigeravatar; 09-15-2011 at 08:43 AM. Reason: Corrected UDF author's name

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Lookup and concatenate all matching entries in closed workbook

    I think that's Mike Rickson
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Lookup and concatenate all matching entries in closed workbook

    @NBVC, oops, you're right, lol. I tried to give credit to an Oregon politician, hehe

  5. #5
    Registered User
    Join Date
    04-12-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    67

    Re: Lookup and concatenate all matching entries in closed workbook

    Thanks tigeravatar, that's a nice UDF. However, it doesn't seem to work when the data workbook is closed - do you have one that does?

    Chinchin

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Lookup and concatenate all matching entries in closed workbook

    The UDF I wrote, takes a Range argument (for the first and third arguments). For a closed workbook, I would re-write ConcatIf to take arrays for those arguments and hope that Excel will handle the conversion from (closed) sheet range to variant.

    When I get back to my machine (with time to work). I would do a test with these two simple UDF's show the contrast I'm thinking of.

    Please Login or Register  to view this content.
    Then I would open two workbooks. Put those UDF's in Workbook1 and then put these formulas in cells of Workbook1
    =myFunction([Workbook2.xlsm]Sheet1!$A$1)
    =myOtherFunction([Workbook2.xlsm]Sheet1!$A$1)

    do a little fiddling to see if everything works as it should. Then close Workbook2 and see if/how they behave.

    That's how I'd start altering ConcatIf. By checking out how Excel processes references as it its passing arguments to a UDF.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Lookup and concatenate all matching entries in closed workbook

    Did some preliminary testing at lunch. It looks as if Excel performs as I expected. However the conversion from Range to Array will limit the kind of criteria the function will accept, fortunatly, the needs in the OP will be within that limitation.

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Lookup and concatenate all matching entries in closed workbook

    Quote Originally Posted by tigeravatar View Post
    Chinchin,

    This is a common request. Mike Rickson published a great UDF for this, see this post for details:

    http://www.excelforum.com/2593269-post9.html

    Hope that helps,
    ~tigeravatar

    EDIT: I originally stated that Mike Erickson published the UDF
    My name is Mike Erickson. Not a politician, not from Oregon. Just a bloke with a quirky sense of spelling.

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Lookup and concatenate all matching entries in closed workbook

    Here's the modified function. The arguments mirror those of SumIf and, as mentioned above, the criteria will compare equality only.

    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)

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