Solved

I need help with a macro to delete rows

Posted on 2014-04-22
3
281 Views
Last Modified: 2014-04-22
I need help with a macro to delete rows

1. Check column "E" delete all rows completly which has words as remove, cancelled,closed,Closed-first call,Resolved, Rejected and resolved


2. In Column "R" delete all other rows which does not have

TTY.Iyh.Desktop.Dtf
TTY.Iyh.Desktop.Sof
TTY.Imd.Server
TTY.Irh.Network


3. In Column "AA" delete rows that has these cells
Bisteio, Krika
Kuemiud, Riha
Maheqlkr, Hai Vial
Naioeqm, saeh
Naiuak, Trati K


Please note point 1 is delete rows that has these words in row "E" and point 2 is delete all rows which does not have the 4 group names in column "R" and 3rd point is delete just rows that has column "AA" with these 5 names
Thanks
Sample.xlsx
0
Comment
Question by:mtthompsons
3 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40014318
Hi,

pls try

Sub macro()
Application.ScreenUpdating = False
LastRow = Range("E" & Cells.Rows.Count).End(xlUp).Row
For Idx = LastRow To 2 Step -1
    bToBeDeleted = False
    Select Case Range("E" & Idx).Value
        Case "Remove", "Cancelled", "Closed", "Closed-first call", "Resolved", "Rejected and resolved"
            bToBeDeleted = True
    End Select
    Select Case Range("R" & Idx).Value
        Case "TTY.Iyh.Desktop.Dtf", "TTY.Iyh.Desktop.Sof", "TTY.Imd.Server", "TY.Irh.Network"
        Case Else
            bToBeDeleted = True
    End Select
    Select Case Range("AA" & Idx).Value
        Case "Bisteio , Krika", "Kuemiud , Riha", "Maheqlkr, Hai Vial", "Naioeqm , saeh", "Naiuak, Trati K"
            bToBeDeleted = True
    End Select
    
    If bToBeDeleted = True Then
        Range("A" & Idx).EntireRow.Delete
    End If

Next
Application.ScreenUpdating = True
End Sub

Open in new window

WARNING some of the names in the XL File are not the same as in your question

Regards
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40014383
The quickest method is using auto filters (you will see a significant difference in large datasets) , for multiple criteria (as in your case) you can create an array with the values and loop thru the array.
Ron de Bruin has a nice example on his website http://www.rondebruin.nl/win/winfiles/MoreDeleteCode.txt
0
 

Author Comment

by:mtthompsons
ID: 40014447
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question