Hello,
I have a spreadsheet i need to pull data from. Column C has "Alternate ID#s" that sometimes show up multiple times. I need a way to delete each row that has a value in column C represented more than once.
The below code is instant, but retains the first instance. I need every row with a duplicate to be deleted, including the original instance. Any help would be appreciated.
' test3 Macro
'
Dim Cl As Range, Rng As Range
With CreateObject("scripting.dictionary")
For Each Cl In Range("C1", Range("C" & Rows.Count).End(xlUp))
If Not .exists(Cl.Value) Then
.Add Cl.Value, Nothing
Else
If Rng Is Nothing Then Set Rng = Cl Else Set Rng = Union(Rng, Cl)
End If
Next Cl
End With
If Not Rng Is Nothing Then Rng.EntireRow.Delete
'
End Sub
I have a spreadsheet i need to pull data from. Column C has "Alternate ID#s" that sometimes show up multiple times. I need a way to delete each row that has a value in column C represented more than once.
The below code is instant, but retains the first instance. I need every row with a duplicate to be deleted, including the original instance. Any help would be appreciated.
' test3 Macro
'
Dim Cl As Range, Rng As Range
With CreateObject("scripting.dictionary")
For Each Cl In Range("C1", Range("C" & Rows.Count).End(xlUp))
If Not .exists(Cl.Value) Then
.Add Cl.Value, Nothing
Else
If Rng Is Nothing Then Set Rng = Cl Else Set Rng = Union(Rng, Cl)
End If
Next Cl
End With
If Not Rng Is Nothing Then Rng.EntireRow.Delete
'
End Sub
part number | description | alt id |
apple | ||
apple | ||
banana | ||
orange | ||
pear | ||
pear | ||
grapefruit | ||
raisin | ||
raisin | ||
raisin | ||
tomato | ||
celery | ||
banana | ||
potato | ||
grape |