[Solved] Delete rows that DON’T meet VBA criteria


This will delete rows that don’t equal a whole number when divided by 50

Sub Button1_Click()
    Dim FrstRng As Range, Lrw As Long
    Dim UnionRng As Range
    Dim c As Range

    Lrw = Cells(Rows.Count, "A").End(xlUp).Row
    Set FrstRng = Range("A2:A" & Lrw)

    For Each c In FrstRng.Cells
        If Int(c / 50) / (c / 50) <> 1 Then
            If Not UnionRng Is Nothing Then
                Set UnionRng = Union(UnionRng, c)    'adds to the range
            Else
                Set UnionRng = c
            End If
        End If
    Next c

    UnionRng.EntireRow.Delete
End Sub

0

solved Delete rows that DON’T meet VBA criteria