+ Reply to Thread
Results 1 to 12 of 12

Vlookup & return all unique values to a single cell

  1. #1
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Angry Vlookup & return all unique values to a single cell

    Hey all, I have been googling till i cant google no more. I am trying to do what a guy in the thread below is asking but i do not see it really answered.

    Original Thread: http://www.ozgrid.com/forum/showthread.php?t=25239

    Here is his sample:
    ColumnA-----------ColumnB
    ABC----------------123
    ABC----------------456
    ABC----------------678
    XYZ----------------444
    XYZ----------------555

    What is not answered is his second part: "But I am really and idiot with VBA. What happens if I only want to return a single instance of duplicated data?" How do can i get the data to show up like this:

    Cell C1 -> 123, 456, 678
    Cell C2 -> 444, 555

    My data does NOT always have 3 digits nor does it just have numbers. I have to do this on 16K+ lines in 3 different categories and having a very hard time figuring out how to do this.
    Last edited by PY_; 06-21-2013 at 09:15 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Vlookup & return all unique values to a single cell

    This may not be the exact answer, but how about...
    Attached Files Attached Files
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Vlookup & return all unique values to a single cell

    Thanks for the response but it still duplicates the values. If you duplicate A1:B1 to row 6 and adjust your range, you get "123, 456, 678, 123" as the value. I am trying to not duplicate the values.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Vlookup & return all unique values to a single cell

    Try the attached
    Attached Files Attached Files

  5. #5
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Vlookup & return all unique values to a single cell

    This one has the same problem. If you duplicate A1:B1 to row 6 and run it, you get "123456678123" as the value. 123 is repeating itself.

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

    Re: Vlookup & return all unique values to a single cell

    PY_,

    Attached is an example file based on the criteria you described.
    Row 1 is a header row so actual data starts in row2
    Column A contains the ABC/XYZ stuff
    Column B contains the numbers
    Column D is a unique list from columns A (I used the Advanced Filter)
    Column E is the list of unique items from column B, and is obtained by using this array formula in cell E2 and copied down. Note that array formulas must be entered with Ctrl+Shift+Enter and not just Enter. That's how the formula gets surrounded by the curly brackets {}, do not try to add those manually.
    Please Login or Register  to view this content.
    The ConcatAll function is a UDF I created (original thread here: http://www.excelforum.com/tips-and-t...geravatar.html). The code being used is from post #8 in that thread:
    Please Login or Register  to view this content.

    As you can see it only returns the unique values and does not repeat them. If you need a pure VBA solution and not a UDF, let me know and I can provide that.
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Vlookup & return all unique values to a single cell

    tigeravatar - Thanks! This works great. With the amount of data I have, the function really tasks my pc but its getting the job done. Thanks again!

  8. #8
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Vlookup & return all unique values to a single cell

    If you do have a VBA solution, I would definitely be interested in that! I have 75,000 rows of data it has to chug through and eventhough im running a decent 8core machine, its taking a long time to calculate. I have to do this for (3) different worksheets all with the same number of rows per sheet.

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

    Re: Vlookup & return all unique values to a single cell

    Pl try this code ,which is modified code of AB33. (It is assumed that column AAA & AAB are free, if not change in the code for suitable columns)

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Vlookup & return all unique values to a single cell

    could make use of a pivot table to summarize you data and then build the output combinations from that?

    How unique are your 75k rows?
    Cheers
    Andy
    www.andypope.info

  11. #11
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Vlookup & return all unique values to a single cell

    Although tigeravatar's solution did work, it ran slower than a two step process i cam up with i already had in place. I am on a time crunch to get this report done by Monday morning so i went with the two step process. It took 12 hours to run just the code and still i have a lot of manual work to do looking up data on a map and adjusting multipliers based on location. Thank goodness this is a one time deal (really once a year) so i will not have to do it again for a while. I did make notes in my VBA of everything i did.

    kvsrinivasamurthy - Thank you for the input. I will sit down and try that one as well after i turn the report in to see if its a better solution than what i currently have.

    Andy - Since this is a one time use with data that will not be the same next year, a pivot table will not work. It would take too long to set it up for my needs.

  12. #12
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Vlookup & return all unique values to a single cell

    I think you may want to look at Andy's idea again, although your current needs are met, Pivot Tables (properly defined) can be a great resource...at least give it a shot
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

+ 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