Results 1 to 10 of 49

Thread: LookUp Value and Concatenate All Found Results

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    Hi Rick,

    I was wondering whether this code could perform the same task (or am I overloooking something ?)

    Code:
    Function search_con_snb(sp As Range, c01 As String)
        sn = sp.Value
        For j = 1 To UBound(sn)
            c02 = c02 & "|" & Join(Application.Index(sn, j), "|")
        Next
        search_con_snb = Join(Filter(Split(c02, "|"), c01), "|")
    End Function
    sp is the range to look in
    c01 is the string to be looked for.
    | is the concatenation delimiter

    e.g to look for "rick" in range A1:B2000 and concatenate by a | all cell values in which 'rick' has been found and put the result into cell F1:

    =search_con_snb(A1:B2000,"rick")

    PS. Basically I consider every multiple search as a filter (autofilter, advancedfilter, VBA-filter) operation.

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837
    https://www.eileenslounge.com/viewtopic.php?f=21&t=40701&p=314836#p314836
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314621#p314621
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314619#p314619
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314600#p314600
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314599#p314599
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314274#p314274
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314229#p314229
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314195#p314195
    https://www.eileenslounge.com/viewtopic.php?f=36&t=39706&p=314110#p314110
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314081#p314081
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314078#p314078
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314062#p314062
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314054#p314054
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313971#p313971
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313909#p313909
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40574&p=313879#p313879
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313859#p313859
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313855#p313855
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 03-02-2024 at 02:58 PM.

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by snb View Post
    I was wondering whether this code could perform the same task (or am I ovrloooking something ?)

    Code:
    Function search_con_snb(sp As Range, c01 As String)
        sn = sp.Value
        For j = 1 To UBound(sn)
            c02 = c02 & "|" & Join(Application.Index(sn, j), "|")
        Next
        search_con_snb = Join(Filter(Split(c02, "|"), c01), "|")
    End Function
    sp is the range to look in
    c01 is the string to be looked for.
    | is the concatenation delimiter
    Our functions are quite different from each other. My function looks in a row or column and, if it finds a match, can return concatentations of values from a different range (sort of like how SUMIF works, but with text and concatenation rather than numbers and summation). Within that functionality, the UDF allows the user to control whether the search is case sensitive or not and whether the search should match the entire contents of the cells it searches or just find the text somewhere within the cell. It also allows you to filter the return list so that all items are returned from the ReturnRange or so that repeated items are listed only once. Also, the function allows the delimiter to be set by the user rather than hard-coding it into the body of the function.
    Last edited by Rick Rothstein; 07-06-2012 at 07:15 AM.

  3. #3
    Junior Member
    Join Date
    Dec 2014
    Posts
    3
    Rep Power
    0
    Hi Rick ,

    I have tried your solution , at first it is all working well, but when I open it again there are some errors

    =LookUpConcat(A2,$A$2:$A$20,$C$2:$C$20,", ")

    A2 is the lookup where as it came out as #VALUE!
    and then the final result came out as NAME?
    Pictures 1.jpgPictures 2.jpgNAME?

    anyway of fixing this ?
    Many thanks

  4. #4
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by jeffwtn View Post
    Hi Rick ,

    I have tried your solution , at first it is all working well, but when I open it again there are some errors

    =LookUpConcat(A2,$A$2:$A$20,$C$2:$C$20,", ")

    A2 is the lookup where as it came out as #VALUE!
    and then the final result came out as NAME?
    Pictures 1.jpgPictures 2.jpgNAME?

    anyway of fixing this ?
    Many thanks
    Assuming there is no sensitive data... can you post a copy of the workbook so I can debug the problem with a live sheet? If there is sensitive data, can you delete it without affecting the problem you are reporting and then post of copy of that modified workbook instead?

  5. #5
    Junior Member
    Join Date
    Dec 2014
    Posts
    3
    Rep Power
    0
    Quote Originally Posted by Rick Rothstein View Post
    Assuming there is no sensitive data... can you post a copy of the workbook so I can debug the problem with a live sheet? If there is sensitive data, can you delete it without affecting the problem you are reporting and then post of copy of that modified workbook instead?
    Sample attached. Thanks for your help.
    Attached Files Attached Files

  6. #6
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by jeffwtn View Post
    Sample attached. Thanks for your help.
    I think Admin posted the solution for you in Message #32... you need to save the workbook as an "Excel Macro-Enabled Workbook (*.xlsm)" and NOT as plain "Excel Workbook (*.xlsx)". When you save the workbook with the macro code in place, click the drop-down under the "File name" field (it is labeled "Save as type:") and select what should be the second item in the list (with the wording I show above). After that, when you reopen the workbook, you will have to click the button to enable the macro code.

  7. #7
    Junior Member
    Join Date
    Dec 2014
    Posts
    3
    Rep Power
    0
    Quote Originally Posted by Rick Rothstein View Post
    I think Admin posted the solution for you in Message #32... you need to save the workbook as an "Excel Macro-Enabled Workbook (*.xlsm)" and NOT as plain "Excel Workbook (*.xlsx)". When you save the workbook with the macro code in place, click the drop-down under the "File name" field (it is labeled "Save as type:") and select what should be the second item in the list (with the wording I show above). After that, when you reopen the workbook, you will have to click the button to enable the macro code.
    Hi Thanks,

    I have retry to do it , still not joy. At first even .xlsx working fine but after a while it just does not work anymore
    file attached. Thanks again



    Jeff
    Attached Files Attached Files

  8. #8
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by jeffwtn View Post
    I have retry to do it , still not joy. At first even .xlsx working fine but after a while it just does not work anymore
    file attached. Thanks again
    You have the code installed in the wrong module. Delete what you now have and then go back to Message #1 and read the instructions at the bottom of the article labeled "HOW TO INSTALL UDFs".

Similar Threads

  1. Replies: 5
    Last Post: 06-04-2013, 01:04 PM
  2. Replies: 6
    Last Post: 12-12-2012, 08:03 PM
  3. Lookup lookup lookup just can't make it work
    By work2live in forum Excel Help
    Replies: 1
    Last Post: 12-08-2012, 11:48 PM
  4. Excel found unreadable content
    By zyousafi in forum Excel Help
    Replies: 2
    Last Post: 08-08-2012, 10:41 AM
  5. Concatenate Multiple Lookup Values in Single Cell
    By Admin in forum Download Center
    Replies: 4
    Last Post: 04-06-2012, 09:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •