Excel loop Need help

D

dlh

I have tohe following code and it works for combining the data in
column B1 and B2 into B1 with commas if column A is the same name in A1
and A2. What I am also needing is the data in columns C-E to be merged
as well the same.
Col A ColB
ColC ColD Col E
BRAKE LINE RUBBING, KNOCKING 4 BT93 LY52486 8888
BRAKE LINE RUBBING, KNOCKING 4 BU31 LT91873 2807
DIFFERENTI. TRANSMISSION 4 DU53 LF77113
DOOR INNER HANDLE FUNCTION ISSUE 4 BU33 LW59323 1130
DOOR CUT-OUT WELD ISSUE 4 DU91 LK43454

The output of the script would be:
BRAKE LINE RUBBING, KNOCKING 4,4 BT93,BU31 LY52486,LT91873 8888,2807
DIFFERENTI. TRANSMISSION 4 DU53 LF77113
DOOR INNER HANDLE FUNCTION ISSUE 4 BU33 LW59323 1130
DOOR CUT-OUT WELD ISSUE 4 DU91 LK43454



Set rngColumn = Range("A1", Cells(Rows.Count, 1).End(xlUp))
For Each rngCell In rngColumn
If Len(rngCell.Value) Then
varToMatch = rngCell.Value
lngR = 2
Do While rngCell(lngR, 1).Value = varToMatch
rngCell(1, 2).Value = rngCell(1, 2).Value & ", " &
rngCell(lngR, 2).Value
'rngCell(lngR, 2).EntireRow.Clear
lngR = lngR + 1
Loop
End If
Next
rngColumn.EntireRow.Sort key1:=Range("A1")
End Sub
 
T

Tom Ogilvy

Set rngColumn = Range("A1", Cells(Rows.Count, 1).End(xlUp))
For Each rngCell In rngColumn
If Len(rngCell.Value) Then
varToMatch = rngCell.Value
lngR = 2
Do While rngCell(lngR, 1).Value = varToMatch
for j = 2 to 4
rngCell(1, j).Value = rngCell(1, j).Value & ", " & _
rngCell(lngR, j).Value
Next j
'rngCell(lngR, 2).EntireRow.Clear
lngR = lngR + 1
Loop
End If
Next
rngColumn.EntireRow.Sort key1:=Range("A1")
End Sub
 
Top