Avatar of Seamus2626
Seamus2626
Flag for Ireland

asked on 

Adjust Delete Code

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

Microsoft Excel

Avatar of undefined
Last Comment
Seamus2626

8/22/2022 - Mon