Group and Delete
Kirk,
One way might be this (untested):
Assuming that CustID is in column A
''''''''''''''''''''''''''
Sub DeleteExcessID()
Dim x As Long
Application.ScreenUpdating = False
' screen updating off speeds up code execution
For x = 500 To 1 Step -1
' set x = whatever you need
If Len(Cells(x, 1)) 0 And Cells(x, 1) = Cells(x + 1, 1) Then
' tests for something in cell and if cell = to cell below
Rows(x).Delete
End If
Next
Application.ScreenUpdating = True
End Sub
''''''''''''''''''''''''''''
hth
--
steveb
(Remove 'NOSPAM' from email address if replying direct)
"Kirk P." wrote in message
...
I'm looking for a procedure that would select the last row within a group
and delete all rows BUT the last row. For example:
CustID CustName Sales
1000 Acme Corp 100
1000 Acme Corp 150
1000 Acme Corp 200
1001 Navy Corp 50
1001 Navy Corp 25
1001 Navy Corp 10
I want to select the LAST row within each CustID group, and delete all
other rows BUT the last row. Any ideas?
|