Removing Duplicates and Pasting

G

Guest

Hi, the following code is meant to loop through column E - 100 Clients (many
duplicated) and paste each client (without duplicates) to Column B of current
wks

Not quite working but i think im close - help is greatly appreciated, thks

Sub rev()

Dim LastRow As Long
Dim i, j As Long
LastRow = Worksheets("Jobs").Cells(Rows.Count, 5).End(xlUp).Row
j = 3
For i = LastRow - 1 To 1 Step -1
If Worksheets("Jobs").Cells(i + 1, 5).Value <>
Worksheets("Jobs").Cells(i, 5).Value Then
Worksheets("Jobs").Cells(i + 1, 5).Copy Destination:=Cells(j, 2)
j = j + 1
End If
Next

End Sub
 
T

Tom Ogilvy

Sub rev()

Dim LastRow As Long
Dim i, j As Long
LastRow = Worksheets("Jobs").Cells _
(Rows.Count, 5).End(xlUp).Row
j = 3
For i = 1 To LastRow
If Worksheets("Jobs").Cells(i, 5).Value <> _
Worksheets("Jobs").Cells(i + 1, 5).Value Then
Worksheets("Jobs").Cells(i, 5).Copy _
Destination:=Cells(j, 2)
j = j + 1
End If
Next
End Sub

worked fine if Column E on Jobs is sorted.
 
G

Guest

Thank You Tom

Tom Ogilvy said:
Sub rev()

Dim LastRow As Long
Dim i, j As Long
LastRow = Worksheets("Jobs").Cells _
(Rows.Count, 5).End(xlUp).Row
j = 3
For i = 1 To LastRow
If Worksheets("Jobs").Cells(i, 5).Value <> _
Worksheets("Jobs").Cells(i + 1, 5).Value Then
Worksheets("Jobs").Cells(i, 5).Copy _
Destination:=Cells(j, 2)
j = j + 1
End If
Next
End Sub

worked fine if Column E on Jobs is sorted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top