Adjust Delete Code

Seamus2626
Seamus2626 used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Yes, just change this:

.Range("A1").AutoFilter Field:=9, Criteria1:="0"

to this:

.Range("A1").AutoFilter Field:=18, Criteria1:="MCI"

jppinto

Author

Commented:
Thanks jppinto!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial