duplicate row not found

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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,187,188
Messages
5,962,103
Members
438,585
Latest member
peterLEE0223

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top