wwbwb
Well-known Member
- Joined
- Oct 20, 2003
- Messages
- 513
I got this code from this forum and it seems to work fine except for one problem. It errors everytime there are no duplicates to delete. Any ideas?
Code:
Sub dupremove()
Application.ScreenUpdating = False
Dim mylastcell As Long
mylastcell = Cells.SpecialCells(xlCellTypeLastCell).Row
With Sheets("stock history").Range("ba1:ba" & mylastcell)
.Formula = _
"=RC[-25]&RC[-24]&RC[-23]&RC[-22]&RC[-21]&RC[-20]&RC[-19]&RC[-18]&RC[-17]&RC[-16]"
End With
With Sheets("stock history").Range("bb1:bb" & mylastcell)
.Formula = "=IF(COUNTIF(RC[-1]:R" & mylastcell & "C26,RC[-1])>1,"""",FALSE)"
.Value = .Value
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
.Clear
End With
With Sheets("stock history").Range("ba1:ba" & mylastcell)
.Clear
End With
Application.ScreenUpdating = True
End Sub