Forum Discussion

Re: Deleting Rows based on a criteria

LesKing 

Sub Delete_not_required()

Dim rng As Range
Dim startData As Variant
Dim resultData As Variant
Dim i As Long
Dim lastrow As Long
Dim k As Long
Dim j As Long

Range("M:U").Clear

lastrow = Range("B" & Rows.Count).End(xlUp).Row
Set rng = Range("A2:I" & lastrow)

startData = rng.Value
ReDim resultData(1 To rng.Rows.Count, 1 To 9)

k = 1

For i = 1 To UBound(startData, 1)
    If startData(i, 9) <> "Not required" Then
    For j = 1 To 9
       resultData(k, j) = startData(i, j)
       
    Next j
    k = k + 1
    End If
    
Next i

Range("M2").Resize(k, 9) = resultData

End Sub

1 Reply

  • LesKing's avatar
    LesKing
    Brass Contributor
    Thanks for your reply Oliver. I had already got a reply from Hans Vogelaar which worked perfectly, doing exactly what I needed. So I'm going with that. But thank you so much for all your effort.
    Les King

Resources