Delete rows if data changes in particular column

  • Thread starter Thread starter jscorsone
  • Start date Start date
J

jscorsone

Hi, I'm seeking assistance with a macro. I'm trying to delete subsequent
rows if data in a particular cell in Column B changes.

I need to create a macro because there are thousands of products and using
autofilter to sort and delete would take a while.

Any assistance would be greatly appreciate, thanks!
 
Sure, I didn't explain that very well.

I have 6 columns of data, thousands of rows of data.

Columns B, C, D, E, F will change. The column I'm concerned with is Column
B, Item Number. There are multiple rows of data with the same Item Number
(Column B.)

I'd like to delete all rows after the first row for a particular item name,
until Column B changes to a new number.
 
for
1
1
1
2
2
3
this will leave
1
2
3
Sub deletedups()
mc = "b"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i).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

Back
Top