+ Reply to Thread
Results 1 to 2 of 2

Thread: Data consolidation from duplicate records

  1. #1
    Registered User
    Join Date
    11-30-2010
    Location
    minneapolis mn
    MS-Off Ver
    Excel 2010
    Posts
    1

    Data consolidation from duplicate records

    I am trying to consolidate the data from multiple records into one large record.
    I am attaching a file sheet 1 is raw data and sheet 2 has an example of the desired outcome. I have been trying pretty much all the macros I can find I just don't know how to get things to work correctly. The example table has only a fraction of the data (6600 rows) with ~1200 unique compounds. Each compound has about 12 columns that I would like to populate from various sources. For example, column A contains compound name, Column B contains source, Column C contains time, etc. but I have 10 different spread sheets with various amounts of data for each compound so I have combined them and now I have ten duplicate records or more. I just want a macro that searches the compound list and enters the data in the correct column of a master list in this case sheet 2, if it encounters data already present in that column I would like the two pieces of data to be added together with a comma separator. So I figured I'd start with a master list of compounds and update each record I have got that pretty well managed using vlookup, but I can only get it to add the first instance to the master sheet so then it only populates to list with the data contained in the first time it encounters the compound name.

    THANKS SO MUCH I AM PULLING MY HAIR OUT>>>>
    Sorry I am using office 2010 FYI
    Attached Files Attached Files

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Data consolidation from duplicate records

    I am not sure how efficient it will be in the end, but here is one way:

    Add this UDF by Harlan Grove to your VB editor (Alt+F11, Insert>>Module and then Paste)

    Function aconcat(a As Variant, Optional sep As String = "") As String
    ' Harlan Grove, Mar 2002
    Dim y As Variant
    
    If TypeOf a Is Range Then
    For Each y In a.Cells
    aconcat = aconcat & y.Value & sep
    Next y
    ElseIf IsArray(a) Then
    For Each y In a
    aconcat = aconcat & y & sep
    Next y
    Else
    aconcat = aconcat & a & sep
    End If
    
    aconcat = Left(aconcat, Len(aconcat) - Len(sep))
    End Function
    Then in Sheet2, B2, add formula:

    =SUBSTITUTE(SUBSTITUTE(TRIM(aconcat(IF(sheet1!$A$2:$A$30=A2,SUBSTITUTE(sheet1!$B$2:$B$30," ","^^"),"")," "))," ",","),"^^"," ")
    adjust ranges to suit your database size and then confirm the formula with CTRL+SHIFT+ENTER not just ENTER.. you should see { } brackets appear.

    Then copy formula down.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0