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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,322
Messages
5,769,453
Members
425,548
Latest member
macjagger17

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