Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I need help with a macro to delete rows

Posted on 2014-04-22
3
Medium Priority
?
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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.

664 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