Macro to compare two list

D

DGillham

Hi!

I have two worksheets. On the Master list I have a list of cars wit
their Registration numbers and vehicle details, the other has jus
registrations only. I wish to compare the two lists, and remove fro
the Master list
any vehicle that is on the registration list only.

I've been able to use the Macro from the Microsoft website, but thi
only removes the duplicate registration numbers, not the entire ro
relating to this registration number. Has anyone any idea how I modif
this macro to delete the row, not just the cell?

Sub DelDups_TwoLists()
Dim iListCount As Integer
Dim iCtr As Integer

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = True


' Get count of records to search through (list that will be deleted).
iListCount = Sheets("Master").Range("A1:A2500").Rows.Count

' Loop through the "master" list.
For Each x In Sheets("Sheet2").Range("A1:A2500")
' Loop through all records in the second list.
For iCtr = 1 To iListCount
' Do comparison of next record.
' To specify a different column, change 1 to the column number.
If x.Value = Sheets("Master").Cells(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Master").Cells(iCtr, 1).Delete xlShiftUp
' Increment counter to account for deleted row.
iCtr = iCtr + 1
End If
Next iCtr
Next
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub

Thanks in advance
Darre
 
D

DGillham

Thanks for that, much appreciated. Taking it one step further, how
could I get it to remove this row, paste it onto another worksheet and
then resume the file comparison process?

Thanks again

Darren
 

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