M
Mike Armstrong
Hi everyone,
I'm looking for some help with aligning the duplicates in two lists. I have
a list of reference numbers (call them A,B,C,D,E,F,G,H) in one column and a
sub set of them (say C,E,G) in another column. I need C in column 1 to be on
the same row as C in column 2, E matching E etc and blank cells in between.
Any ideas?
I've been playing with the following code which I took from a duplicate
deletion macro on support.microsoft.com and have tried to make work, but I'm
getting nowhere.
Sub DelDups_TwoLists()
Dim iListCount As Integer
Dim iCtr As Integer
' Get count of records to search through (list that will be deleted).
iListCount = Sheets("sheet1").Range("H1:H100").Rows.Count
' Loop through the "master" list.
For Each x In Sheets("Sheet1").Range("A1:A100")
' 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("Sheet1").Cells(iCtr, 8).Value Then
' If match is true then delete row.
Sheets("Sheet1").Cells(iCtr, 8).Insert Shift:=xlDown
End If
Next iCtr
Next
MsgBox "Done!"
End Sub
Thanks very much
-Mike
www.trickswithhats.org
I'm looking for some help with aligning the duplicates in two lists. I have
a list of reference numbers (call them A,B,C,D,E,F,G,H) in one column and a
sub set of them (say C,E,G) in another column. I need C in column 1 to be on
the same row as C in column 2, E matching E etc and blank cells in between.
Any ideas?
I've been playing with the following code which I took from a duplicate
deletion macro on support.microsoft.com and have tried to make work, but I'm
getting nowhere.
Sub DelDups_TwoLists()
Dim iListCount As Integer
Dim iCtr As Integer
' Get count of records to search through (list that will be deleted).
iListCount = Sheets("sheet1").Range("H1:H100").Rows.Count
' Loop through the "master" list.
For Each x In Sheets("Sheet1").Range("A1:A100")
' 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("Sheet1").Cells(iCtr, 8).Value Then
' If match is true then delete row.
Sheets("Sheet1").Cells(iCtr, 8).Insert Shift:=xlDown
End If
Next iCtr
Next
MsgBox "Done!"
End Sub
Thanks very much
-Mike
www.trickswithhats.org