Results 1 to 5 of 5

Merge Rows of duplicates??

Threaded View

anixan Merge Rows of duplicates?? 06-25-2011, 01:42 PM
MarvinP Re: Merge Rows of duplicates?? 06-25-2011, 01:59 PM
anixan Re: Merge Rows of duplicates?? 06-25-2011, 02:24 PM
MarvinP Re: Merge Rows of duplicates?? 06-25-2011, 03:12 PM
consigliere Re: Merge Rows of duplicates?? 01-09-2013, 12:45 PM
  1. #1
    Registered User
    Join Date
    06-25-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Exclamation Merge Rows of duplicates??

    Hi,

    I am trying to merge rows of duplicate entries, say I have the following information in a excel spreadsheet:

    Column A: Name
    Column B: First Line of Address
    Column C: Area
    Column D: County
    Column E: Post Code
    Column F: Tel Number

    A|B|C|D|E|F
    Dave | Rice Rd | Liverpool | Merseyside | L45 7HT | 6381754
    Tony | Hill Grove | Runcorn | Merseyside | L78 9JU | 6527897
    Mark | Rice Rd | Liverpool | Merseyside | L45 7HT | 6381754
    John | Lime Ave | Runcorn | Merseyside | L34 9HF | 7248853


    If I have the data above in my spreadsheet I want to basically search and look at columns B,C,D,E and F and then if there are any duplicates of these for that row anywhere on the sheet I want it to merge the Data for those duplicate as shown below:

    A|B|C|D|E|F
    Dave, Mark | Rice Rd | Liverpool | Merseyside | L45 7HT | 6381754
    Tony | Hill Grove | Runcorn | Merseyside | L78 9JU | 6527897
    John | Lime Ave | Runcorn | Merseyside | L34 9HF | 7248853

    I have managed to find a macro that is shown below however this macro only looks at 1 column and then merges the data based on that which is not what I want. Usually I would just create this myself if it where in any other language however I cant seem to get this to work and would really appreciate the help.

    Sub kTest()
    Dim a, i As Long, w(), c As Long, z
    With Range("a1")
        a = .CurrentRegion
        With CreateObject("scripting.dictionary")
            .comparemode = vbTextCompare
            For i = 2 To UBound(a, 1)
                If Not IsEmpty(a(i, 1)) Then
                    If Not .exists(a(i, 1)) Then
                        ReDim w(1 To UBound(a, 2))
                        For c = 1 To UBound(a, 2): w(c) = a(i, c): Next
                        .Add a(i, 1), w
                    Else
                        w = .Item(a(i, 1)): w(1) = a(i, 1)
                        For c = 2 To UBound(a, 2)
                            w(c) = .Item(a(i, 1))(c) & Chr(10) & a(i, c)
                        Next
                        .Item(a(i, 1)) = w
                    End If
                End If
            Next
            z = .items
        End With
        .CurrentRegion.Offset(1).ClearContents
        For i = 0 To UBound(z)
            .Offset(i + 1).Resize(, UBound(z(i))).Value = z(i)
        Next
    End With
    End Sub
    Thanks
    Last edited by anixan; 06-25-2011 at 02:22 PM.

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