HowdeeDoodee
Well-known Member
- Joined
- Nov 15, 2004
- Messages
- 599
I do not know where I got this code, probably here. The code deletes dups in each sekected row, going across, column to column for a few rows. However, I cannot get the code to work on a whole sheet. Can anyone change the code or give me new code to do what this code is supposed to do?
Example of what the code is supposed to do for the whole sheet:
Before:
Row1.....apple.....apple....pear....peach
Row2....people....cats....cats....apple
Row3....TV....radio....TV....car
Row4....car....nice....code....car
After:
Row1.....apple....pear....peach
Row2....people....cats....apple
Row3....TV....radio....car
Row4....car....nice....code
Thank you in advance for any replies.
Example of what the code is supposed to do for the whole sheet:
Before:
Row1.....apple.....apple....pear....peach
Row2....people....cats....cats....apple
Row3....TV....radio....TV....car
Row4....car....nice....code....car
After:
Row1.....apple....pear....peach
Row2....people....cats....apple
Row3....TV....radio....car
Row4....car....nice....code
Code:
Sub RemoveDupsAcrossARowColumnByColumn()
'Remove Duplicates in Every row, going across, column to colunn
Dim Cell As Variant
Do Until ActiveCell = ""
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
For Each Cell In Selection
If WorksheetFunction.CountIf(Selection, Cell) > 1 Then
Cell.ClearContents
Else
End If
Next Cell
On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
ActiveCell.Range("A2").Select
Loop
End Sub
Thank you in advance for any replies.