Combining Duplicates
Hi Joannie,
Am Thu, 9 May 2013 23:17:21 +0200 schrieb Claus Busch:
For i = LRow To 2 Step -1
If Cells(i, 3) & Cells(i, 4) = _
Cells(i - 1, 3) & Cells(i - 1, 4) Then
Cells(i - 1, 2) = Cells(i - 1, 2) & _
" / " & Cells(i, 2)
Rows(i).Delete
End If
Next
in your example you have some spaces in your strings. Then you better
try:
Sub Test()
Dim LRow As Long
Dim i As Long
Application.ScreenUpdating = False
LRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = LRow To 2 Step -1
With WorksheetFunction
If .Trim(Cells(i, 3) & Cells(i, 4)) = _
.Trim(Cells(i - 1, 3) & Cells(i - 1, 4)) Then
Cells(i - 1, 2) = Cells(i - 1, 2) & _
" / " & Cells(i, 2)
Rows(i).Delete
End If
End With
Next
Application.ScreenUpdating = True
End Sub
Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
|