Hiya,
I was able to locate a macro that does exactly what I need; however, I need to make a slight change to the but I have limited vba knowledge and am hoping someone can help me.
I have a spreadsheet that lists employees and their certifications. If an employee has multiple, then they will show up on as many rows as they have certifications.
The macro I have merges them into one row with a line break, but only the first column's unique value has been merged while the other columns containing their own unique values are duplicated when I want them to show up only once. Example: Jane Doe shows up 2 times on the report. Her name should only show up once on the row, not 2 times with a line break.
Here is the code. I have also attached an example of what I need. Because the attachment is a simpler version of the actual report, is it possible to specify which rows have the unique values and which ones don't? Any help is appreciated.
Sub Test()
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
Bookmarks