View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Delete rows with duplicate information

Sub Removed_Duplicates()

LastRow = Cells(Rows.Count, "D").End(xlUp).Row

Remove = False
LoopCounter = 1
Do While LoopCounter <= LastRow
If IsEmpty(Cells(LoopCounter, "F")) Then

MyDate = Cells(LoopCounter, "D").Value
Employee = Cells(LoopCounter, "E").Value

For RowCount = 1 To LastRow
If RowCount < LoopCounter Then

If (Cells(RowCount, "D").Value = MyDate) And _
(Cells(RowCount, "E").Value = Employee) Then

Remove = True
End If

End If

Next RowCount

End If

If Remove = True Then
Rows(LoopCounter).Delete
Remove = False
Else
LoopCounter = LoopCounter + 1
End If
Loop
End Sub

"Ixtreme" wrote:

I have a sheet on which I import data from an external source. After
importing data, I need something to remove complete rows that match a
specific criteria.

For example:

I have in Column D a Date and in column E an EmployeeName and in
column F and OrderNumber.

after my import, I need some vba that runs through my data quickly to
remove all existing rows that have the same Date, the same
EmployeeName and an empty OrderNumber.

For example
D E F
row 50) 17-08-2007 Mark 12345
row 60) 17-08-2007 Mark
row 62) 17-08-2007 John

In this case, only row 60 should be removed

Thank you very much