macro to delete hidden or unused rows

C

Cam

Hello,

Here is what I am trying to achieve. For order with multiple oper, it only
returns one order with the lowest oper number. I need help with a macro to
filter out so only the first operation of each Order number and then delete
all the rows that are not needed. Thanks

Table with the following data:
Part Order Oper WC Date
AAA 123 1000 8951 1/2/08
AAA 123 2000 8951 1/3/08
AAA 123 3000 8951 1/7/08
AAA 123 4000 8951 1/3/08
ABC 205 5000 8951 1/4/08
ABC 205 6000 8951 1/8/08
ABZ 314 1000 8951 1/3/08
AAH 380 2000 8951 1/3/08

result of query data I like to achieve:
Part Order Oper WC Date
AAA 123 1000 8951 1/2/08
ABC 205 5000 8951 1/4/08
ABZ 314 1000 8951 1/3/08
AAH 380 2000 8951 1/3/08

Rows to be deleted or moved to some else where:
AAA 123 2000 8951 1/3/08
AAA 123 3000 8951 1/7/08
AAA 123 4000 8951 1/3/08
ABC 205 6000 8951 1/8/08
 
G

Gary''s Student

Sub cam()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = n To 2 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
If Cells(i, 2).Value = Cells(i - 1, 2).Value Then
Cells(i, 1).EntireRow.Delete
End If
End If
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