• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help -how to delete multiple rows containing different text in different columns

Hi

I would like to know how to delete multiple rows containing different text (sample below) which I can include in my macro.




Colunm B contains text : "Invoice ", " Payment" and PO

Column C contains text : "Germany" , "Poland" and UK

Column D contains text : " Paid" ," outstanding" and Overdue

Column E contains text : " Scope" ,"not in scope"

The rows should be deleted upon satisfying the above criteria.

Please help me on extending the below code



Sub Test()

Dim ws As WorksheetDim lastRow AsLong, i AsLongDim value AsString

Set ws = ActiveWorkbook.Sheets("*Name of Worksheet")
lastRow = ws.Range("D"& ws.Rows.Count).End(xlUp).Row

' Evaluate each row for deletion.' Go in reverse order so indexes don't get messed up.
For i = lastRow To2Step-1
value = ws.Cells(i,4).Value ' Column D value.

' Check if it contains one of the keywords.If Instr(value,"INVOICE")=0 _And Instr(value,"PAYMENT")=0 _And Instr(value,"P.O.")=0 _Then

' Protected values not found. Delete the row.
ws.Rows(i).Delete
EndIfNext

EndSub


Sub MultiDelete()

With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
For Each cell In Range("A4:A200")
Select Case cell.Value
Case "Name1", "Name2", "Name3"
cell.EntireRow.Delete
End Select
Next cell
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
 
Hi !

Do not forget to use code tags within your post as per forum rules.

Different ways, as it depends on the total rows number
and how many rows to delete …
 
Sorry Marc for not following the forum rules..

I want to delete every row that has the below criteria from the date I have in one sheet .


Colunm B contains text : "Invoice ", " Payment" and PO

Column C contains text : "Germany" , "Poland" and UK

Column D contains text : " Paid" ," outstanding" and Overdue

Column E contains text : " Scope" ,"not in scope"

The rows should be deleted upon satisfying the above criteria.

Please help me on extending the below code
 
Hi Marc,

To be more clear on the Data part...

I tend to copy data to a sheet from a tool and then will filter column B search for text containing - Invoice ", " Payment" and PO and delete the entire rows ..similarly unfilter and filter again Column C contains text :. "Germany" , "Poland" and UK.....this contiues till as I have mentioned in the above threads.

After which I have the remaining Data which is used for reporting
 
Back
Top