Solved

I need help with a macro to delete rows

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

776 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