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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,214,868
Messages
6,122,005
Members
449,059
Latest member
mtsheetz

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
Back
Top