Hi
Can I just delete duplicated cells in a column BUT without shifting other cells to the top? I used Data-->remove duplicate but that would remove duplicated cells and move everything up.
Thanks
Yeah, it was not wise to use MATCH. COUNTIF will work:@ Flashbond
Your formula needs a tweak as it returns blank or #N/A
@ lezawang
Another manual way
1. Select the column by clicking its heading label
2. Home -> Conditional Formatting -> Highlight Cells Rules -> Duplicate Values -> OK
3. With the column still selected -> Data -> Filter
4. Note the cell colour of the duplicates (probably the default pink colour) & click the filter drop-down in the top cell and choose -> Filter by Color -> Select the appropriate cell color for the duplicates
5. Select from row 2 to the bottom of the visible cells & hit the Delete key
6. Remove the AutoFilter altogether or from the drop-down choose Select All
@ Flashbond
Your formula needs a tweak as it returns blank or #N/A
@ lezawang
Another manual way
1. Select the column by clicking its heading label
2. Home -> Conditional Formatting -> Highlight Cells Rules -> Duplicate Values -> OK
3. With the column still selected -> Data -> Filter
4. Note the cell colour of the duplicates (probably the default pink colour) & click the filter drop-down in the top cell and choose -> Filter by Color -> Select the appropriate cell color for the duplicates
5. Select from row 2 to the bottom of the visible cells & hit the Delete key
6. Remove the AutoFilter altogether or from the drop-down choose Select All
That is correct and it was because in your original post you said remove duplicates could be used except that it moved all the cells up. Remove duplicates also removes all the duplicated values and you didn't mention that was a problem.In your example, it will delete 3 of them A1 A5 and A20
Sub ClearDupes()
Dim Cl As Range
With CreateObject("scripting.dictionary")
For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
If Not .exists(Cl.Value) Then
.Add Cl.Value, Nothing
Else
Cl.ClearContents
End If
Next Cl
End With
End Sub
Sub Clear_Dupes()
With Range("A1", Range("A" & Rows.Count).End(xlUp))
.Value = Evaluate(Replace(Replace("if(#="""","""",if(match(#,#,0)=row(#)-row(^)+1,#,""""))", "#", .Address), "^", .Cells(1).Address))
End With
End Sub