I'm currently creating a worksheets which moves rows in Excel that contain a cell containing the text "Voltooid" to a second worksheet. I want to either move the rows, or copy+paste and delete them, based on cell value.
Up until now, I've been able to build a function that deletes rows in the table. Please see the code below:
Sub DeleteCompleted()
Dim Test1 As ListObject
Dim Test2 As Variant
Dim Rowcount As Integer
Set Test1 = Sheets("To Do Lijst").ListObjects("Table2")
Test2 = Test1.ListRows.Count
For Rowcount = 1 To Test2 Step 1
If Test1.DataBodyRange(Rowcount, 4) = "Voltooid" Then
Test1.DataBodyRange(Rowcount, 4).Delete Shift:=xlUp
Rowcount = 0
End If
Next Rowcount
Can you suggest a better format for me?
Kind regards,
Pim
Step -1
to yourFor
statement. Also settingrRowcount = 0
within yourFor
loop will likely cause problems. – Luuklag