Delete row containing all previous values.

  • Thread starter mohd21uk via OfficeKB.com
  • Start date
M

mohd21uk via OfficeKB.com

I have a column in a spreadsheet with repeated values for e.g a name which
is repeated 5 times I would like to keep the last row containing this value
but delete all previous rows i.e in this example i would like to keep row
five containing the last occourence of this value and delete all previous
rows.
 
D

Don Guillett

try this

Sub deleledupsinpreviousrows()
For i = Cells(Rows.Count, "a").End(xlUp).Row To 2 Step -1
If Cells(i - 1, 1) = Cells(i, 1) Then Rows(i - 1).Delete
Next
End Sub
 

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