Solved

I need help with a macro to delete rows

Posted on 2014-04-22
3
276 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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now