Hi - I need help perfecting my VBA Script for a fairly simple macro.
I have duplicated names in column A, with unique values in column H. I would like to concatenate the values in column H, if column A is the same. And then delete duplicated rows, but have the coordinating concatenate value stay with the respected row.
What I have so far will concatenate the values, but lists them back to back in column I, making it difficult to then delete the duplicate rows. I have attached an image of what this script creates.
Sub ConcatenateCellsIfSameValueExists()
DestRowRef = 2
CheckedCell = Cells(2, "A").Value
For I = 2 To Range("A" & Rows.Count).End(xlUp).Row + 1
If Cells(I, "A").Value <> CheckedCell Then
tempConValues = CheckedCell & " " & tempConValues
Cells(DestRowRef, "I").Value = tempConValues
tempConValues = ""
DestRowRef = DestRowRef + 1
End If
tempConValues = tempConValues & ", " & Cells(I, "H").Value
CheckedCell = Cells(I, "A").Value
Next
End Sub
I have duplicated names in column A, with unique values in column H. I would like to concatenate the values in column H, if column A is the same. And then delete duplicated rows, but have the coordinating concatenate value stay with the respected row.
What I have so far will concatenate the values, but lists them back to back in column I, making it difficult to then delete the duplicate rows. I have attached an image of what this script creates.
Sub ConcatenateCellsIfSameValueExists()
DestRowRef = 2
CheckedCell = Cells(2, "A").Value
For I = 2 To Range("A" & Rows.Count).End(xlUp).Row + 1
If Cells(I, "A").Value <> CheckedCell Then
tempConValues = CheckedCell & " " & tempConValues
Cells(DestRowRef, "I").Value = tempConValues
tempConValues = ""
DestRowRef = DestRowRef + 1
End If
tempConValues = tempConValues & ", " & Cells(I, "H").Value
CheckedCell = Cells(I, "A").Value
Next
End Sub