Delete Dups

S

Stockwell43

Hello,

I have a spreadsheet that has a column that says "Duplicate?". I am trying
to delete thse as there are over 6,000 rows I hate to do this manually. How
can I delete the ones that say Dup in the cell either at once or doing a find
and delete?

Thanks!
 
G

Gary''s Student

Try this small macro:

Sub stockwell()
n = Cells(Rows.Count, "H").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "H").Value = "Duplicate?" Then
Rows(i).Delete
End If
Next
End Sub

This code is for column H. Adapt to suit your needs.
 
M

Mike H

Hi,

I assume this word 'Duplicate' is from a countif formula. If you are trying
to delete duplicates from a column then I wouldn't start from there!!

Select your column with duplicates in then

Data|Filter|Advanced filter
Select 'copy to another location'
Check 'Unique records only'

enter a cell address to copy them to
OK and you now have a unique list to paste on top of the list with
duplicates in

Mike
 
S

Stockwell43

Hi,

I changed the H to E and placed it in a module and ran the macro and id
gives me an error on this line:

If Cells(i, "E").Value = "DUP" Then

It says Type Mismatch.

The column is E and word in that column is DUP. so if DUP is found in that
column, I want the entire rows deleted. I may have explained that incorrectly
the first time. Sorry about that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top