Hi,
I have a simple macro I use to remove duplicate entries.
As an example I have two Adjacent Columns:
Col A is the data that may have duplicates.
Column B is a simple formula:
Cell C1 is a countif() to determine the amount of total rows.
Then I use the following macro to delete the duplicate rows ( the data in Column A is sorted numerically and the formulas in column B are populated outside of this macro. This macro pastes the values in column B, so that the "D" value remains true to the row it's referencing, then [in theory] deletes any row where the value in Column A is a duplicate.):
The problem I'm having is this macro misses several rows, all of which are when Column A has more than 2 duplicate values. In these cases it deletes all except the first of these rows.
Any idea what might be causing this?
Running the above macro twice does catch the ones that are missed from the first run, but I don't understand how the macro is skipping a row when the value in column B is "D", regardless what is above or below it.
Thanks in advance for any help/advice!
I have a simple macro I use to remove duplicate entries.
As an example I have two Adjacent Columns:
Col A is the data that may have duplicates.
Column B is a simple formula:
Code:
=IF(A2=A1,"D",0)
Cell C1 is a countif() to determine the amount of total rows.
Then I use the following macro to delete the duplicate rows ( the data in Column A is sorted numerically and the formulas in column B are populated outside of this macro. This macro pastes the values in column B, so that the "D" value remains true to the row it's referencing, then [in theory] deletes any row where the value in Column A is a duplicate.):
Code:
Sub DupeKill()
DKCount = Range("C1")
Columns("B:B").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
For i = 1 To DKCount
If Cells(i, "B") = "D" Then
Rows(i).Select
Selection.Delete shift:=xlUp
End If
Next i
End Sub
The problem I'm having is this macro misses several rows, all of which are when Column A has more than 2 duplicate values. In these cases it deletes all except the first of these rows.
Any idea what might be causing this?
Running the above macro twice does catch the ones that are missed from the first run, but I don't understand how the macro is skipping a row when the value in column B is "D", regardless what is above or below it.
Thanks in advance for any help/advice!