Solved

I need help with a macro to delete rows

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

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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 26

Expert Comment

by:MacroShadow
Comment Utility
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
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now