+ Reply to Thread
Results 1 to 3 of 3

Merge duplicate rows and combine data in some of the same columns

Hybrid View

  1. #1
    Registered User
    Join Date
    01-23-2013
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    2

    Merge duplicate rows and combine data in some of the same columns

    Have spreadsheet with multiple columns and rows. Where the data in column C matches another in column C, want the information in columns in E:I to be added together. Information in columns A, B, K and L will be the same and should be retained.

    Therefore in the example spreadsheet attached, cells E8 - I9 would be added together, likewise E18 - I19 and row 9 and 19 would disappear.

    Help appreciated to run a macro to achieve.

    KenBook4.xlsx

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Merge duplicate rows and combine data in some of the same columns

    try
    Option Explicit
    
    Sub test()
        Dim dic As Object, i As Long
        Set dic = CreateObject("Scripting.Dictionary")
        With Range("a5").CurrentRegion
            For i = 1 To .Rows.Count
                If Not dic.exists(.Cells(i, 3).Value) Then
                    Set dic(.Cells(i, 3).Value) = .Rows(i).Range("e1:i1")
                Else
                    dic(.Cells(i, 3).Value).Value = _
                    .Parent.Evaluate(dic(.Cells(i, 3).Value).Address & "+" _
                    & .Rows(i).Range("e1:i1").Address)
                    .Rows(i).EntireRow.Delete
                    i = i - 1
                End If
            Next
        End With
    End Sub

  3. #3
    Registered User
    Join Date
    01-23-2013
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Merge duplicate rows and combine data in some of the same columns

    Excellent - works great - thanks jindon

+ 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