LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default very hard deleting rows issue

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Deleting first character issue saman110 via OfficeKB.com New Users to Excel 1 February 21st 08 02:10 AM
printing issue - want to repeat two rows and also 5 rows in column cliffykat Excel Discussion (Misc queries) 0 August 29th 07 10:36 PM
Excel hard code those #'s without deleting the formula or typing# JudiS Excel Discussion (Misc queries) 1 August 1st 05 11:21 PM


All times are GMT +1. The time now is 06:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"