+ Reply to Thread
Results 1 to 2 of 2

Combining multiple rows of data into one row

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Albuquerque, NM USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Combining multiple rows of data into one row

    I am attempting to combine several contact databases and have run into a lot of duplicates. Some rows have more info than others for the same contact. Is there a way to combine duplicate rows based on first and last name into one row and then delete the source rows. Leaving one row with all the information. Or combine all the information into one row and delete the other row. Any help would be greatly appreciated.

    Example.xlsx
    Last edited by RudyDLG; 05-15-2012 at 04:40 PM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Combining multiple rows of data into one row

    try it
    Sub ertert()
    Dim x, y(), i&, j&, k&, n&, s$, ubx&
    x = Intersect(Range("A:J"), ActiveSheet.UsedRange).Value
    Intersect(Range("A:J"), ActiveSheet.UsedRange).Select
    ubx = UBound(x, 2): ReDim y(1 To UBound(x, 1), 1 To ubx)
    
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 1 To UBound(x)
            s = x(i, 1) & "|" & x(i, 3)
            If Len(s) > 1 Then
                If .Exists(s) Then
                    n = .Item(s)
                    For k = 1 To ubx
                        If Len(y(n, k)) = 0 Then y(n, k) = x(i, k)
                    Next k
                Else
                    j = j + 1: .Item(s) = j
                    For k = 1 To ubx
                        y(j, k) = x(i, k)
                    Next k
                End If
            End If
        Next i
    End With
    
    Range("A1").Resize(UBound(x, 1), ubx).Value = y()
    End Sub

+ 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