I have a dataset that contains a bunch of information on customers. I want this information moved into another worksheet when Yes
is entered into the Cell in row
It is generally more efficient to delete all your rows at once.
Set c = Nothing 'reset your range
For i = 1 To 500 'or 500 To 1 Step -1 - doesn't make a difference
If Source.Range("K" & i) = "yes" Then
If c Is Nothing Then
Set c = .Cells(i, 1).EntireRow 'if the range is empty then set it to the required row
Else
Set c = Union(c, .Cells(i, 1)).EntireRow 'otherwise add this row
End If
End If
Next
If Not c Is Nothing Then c.Delete xlUp 'if the range is not empty then delete all the rows
(I should add that my use of Cells(x,y).EntireRow
is purely a personal preference. I always use that format as I find it easier to debug.)