Consulting

Results 1 to 3 of 3

Thread: Solved: Merge/join cells if same ID

  1. #1

    Unhappy Solved: Merge/join cells if same ID

    Hi Everyone. I would like to get some help for a macro. Here is my problem. I have an excel file with many recurring rows. Actually not all the cells in the row are duplicates only the first 3. The cells after them are different. What I would like is the following: instead of three rows to have only one and the cells which are not identical to be joined/merged into one cell. In the attached excel file you will see exactly what I mean.
    Please try to help me as this problem is killing me! Thank you and best regards!
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]Sub ProcessData()
    Dim lastrow As Long
    Dim i As Long

    Application.ScreenUpdating = False

    With ActiveSheet

    lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = lastrow To 3 Step -1

    If .Cells(i, "A").Value = .Cells(i - 1, "A").Value And _
    .Cells(i, "B").Value = .Cells(i - 1, "B").Value And _
    .Cells(i, "C").Value = .Cells(i - 1, "C").Value Then

    .Cells(i - 1, "D").Value = .Cells(i - 1, "D").Value & ";" & _
    .Cells(i, "D").Value
    .Cells(i - 1, "E").Value = .Cells(i - 1, "E").Value & ";" & _
    .Cells(i, "E").Value
    .Cells(i - 1, "F").Value = .Cells(i - 1, "F").Value & ";" & _
    .Cells(i, "F").Value
    .Rows(i).Delete
    End If
    Next i
    End With

    Application.ScreenUpdating = True
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thank you very much xld! It works like charm!
    Thank you very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •