PDA

View Full Version : Solved: delete unwanted data



Pete
11-26-2008, 03:20 AM
see attached workbook.
Hi

Need a macro that will find Wonderwall (in Caps) then find the second heading of wonderwall whatever row it is in column B current it's in row 26.

Then find the last task against wonderwall in our case row 43. And then delete/remove all data from that point onwards downwards.

Bob Phillips
11-26-2008, 03:40 AM
If you only look for two, then you will delete valid data because there is also that text in row 24.

Pete
11-26-2008, 03:46 AM
Hi xld.

thanks for spotting the mistake. OK correction. Can we find in column A RBS_CNY_9530 - 5559

and delete one after this point using this as a unique key.....ignoring column b altogether...

As RBS_CNY_9530 - 5559 will always be the last id........in this table.

Bob Phillips
11-26-2008, 04:09 AM
Why not just delete everything after the last complete entry in column A?

Pete
11-26-2008, 04:52 AM
Why not just delete everything after the last complete entry in column A? that would also work - sir.

i am happy with this method....

Bob Phillips
11-26-2008, 05:05 AM
Public Sub ProcessData()
Dim LastRow As Long
Dim LastRow2 As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
LastRow2 = .Cells(.Rows.Count, "B").End(xlUp).Row
.Rows(LastRow + 1).Resize(LastRow2 - LastRow).Delete
End With

End Sub

Pete
11-26-2008, 05:45 AM
works prefectly sir....

thanks for the excellent feedback