troubleshooting Question

Adjust Delete Code

Avatar of Seamus2626
Seamus2626Flag for Ireland asked on
Microsoft Excel
2 Comments1 Solution166 ViewsLast Modified:
Hi,

I have attached code which deletes Rows where Field 9 is = 0

I want to delete rows where Field 18 = MCI

Can i just change those to parts of the code to achieve this

I.E. Change the filed number and criteria?

Thanks
Seamus
Sub DeleteZeroDepots()


Dim rData As Range

Application.ScreenUpdating = False

With ActiveSheet
    .AutoFilterMode = False
    .Range("A1").AutoFilter Field:=9, Criteria1:="0"
    With .AutoFilter.Range
        On Error Resume Next
        Set rData = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
        If Not rData Is Nothing Then
            rData.EntireRow.Delete
        End If
    End With
    .AutoFilterMode = False
End With




Application.ScreenUpdating = True


End Sub

Open in new window

ASKER CERTIFIED SOLUTION
jppinto

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros