Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your results look wrong to me.
Number Status C02504 Removed c02536 Removed c02536 Added c02536 Added <<<<<<<<<<<<<<<< c02536 Not Changed C02564 Not Changed C03869 Removed C03869 Added C03869 Added <<<<<<<<<<<<<<<< as far as I can see the two chevron marked items are duplicates, so my code deletes them. Tell me in what way they are unique because I can't see it. -- HTH RP (remove nothere from the email address if mailing direct) "Lynn Bales" wrote in message ... Bob This works part of the way. It deletes to much. I don't want it to delete ANY lines for a number that has more than one status. I only need it to delete extra rows when the number and the status match in every case. So for a number that has 3 Adds and nothing else, delete the two extras. For a number that has 2 Adds, 1 Removed and 1 Not Changed, don't delete ANY rows. There is an extra column of data related to these two items I need to preserve but don't want to include because it creates a unique entry for EVERY row. I've tried filtering and it also doesn't work correctly either. Thanks so much! Lynn "Bob Phillips" wrote: Sub Test() Dim iLastRow As Long Dim i As Long Dim delRange As Range iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = 2 To iLastRow If Cells(i, "A").Value = Cells(i - 1, "A").Value And _ Cells(i, "B").Value = Cells(i - 1, "B").Value Then If delRange Is Nothing Then Set delRange = Cells(i, "A") Else Set delRange = Union(delRange, Cells(i, "A")) End If End If Next i If Not delRange Is Nothing Then delRange.EntireRow.Delete Set delRange = Nothing End If End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Lynn Bales" wrote in message ... I have 4000 rows of data that looks like this: Number Status C02504 Removed C02504 Removed C02504 Removed C02504 Removed C02504 Removed C02504 Removed c02536 Removed c02536 Added c02536 Added c02536 Not Changed c02536 Not Changed c02536 Not Changed c02536 Not Changed c02536 Not Changed C02564 Not Changed C03869 Removed C03869 Added C03869 Added What I need to accomplish is to eliminate all but one row where the number and status are the same but keep ALL the rows where the number has several different statuses. So basically I need the above to look like: Number Status C02504 Removed c02536 Removed c02536 Added c02536 Added c02536 Not Changed C02564 Not Changed C03869 Removed C03869 Added C03869 Added |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro for deleting rows and serialising the remaing rows | Links and Linking in Excel | |||
Macro for deleting rows and serialising the remaing rows | Excel Worksheet Functions | |||
Deleting first character issue | New Users to Excel | |||
printing issue - want to repeat two rows and also 5 rows in column | Excel Discussion (Misc queries) | |||
Excel hard code those #'s without deleting the formula or typing# | Excel Discussion (Misc queries) |