Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,064
- Office Version
- 2016
- Platform
- Windows
I am using this to delete duplicates from column B, it work well. only has one problem. Some of the cells have a hyphen in them. I need the code to disregard these and NOT delete them as a duplicate. Therefore any Cells in Sheet3 Column B that have a hyphen are Not to be regarded as duplicates and therefore they are not deleted.
VBA Code:
'''delete duplicates in Sheet3 column B
Dim Cl As Range, Rng As Range
With CreateObject("scripting.dictionary")
For Each Cl In Sheets("Sheet3").Range("B2", Sheets("Sheet3").Range("B" & Rows.Count).End(xlUp))
If Cl <> "" Then
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
End If
Next Cl
End With
If Not Rng Is Nothing Then Rng.EntireRow.Delete