I am importing a range as a 2D Variant into VBA and to declare an array as Variant by `Dim matrix().
I now want to loop through the rows and delete rows where the 2nd column = "even"
or the 5th row ends with "_tom"
. Dataset below
My main issue is that I do not know how to delete that rows?
1, odd, 3, 27, today
2, even, 6, 21, today_tom
3, odd, 9, 28, today
4, even, 12, 30, today
5, odd, 15, 17, today_tom
6, even, 18, 17, today
7, odd, 21, 18, today
8, even, 24, 9 , today_tom
9, odd, 27, 24, today_tom
10, even, 30, 9, today
11, odd, 33, 11, today
12, even, 36, 22, today
13, odd, 39, 8 , today
14, even, 42, 1 , today
15, odd, 45, 4 , today
Current code:
Sub test()
Dim matrix As Variant
matrix = Range("A1:E15")
Dim r As Long
For r = LBound(matrix, 1) To UBound(matrix, 1)
If matrix(r, 2).Value = "even" Then
'delete
End If
If Right(matrix(r, 2).Value, 4) = "_tom" Then
'delete
End If
Next r
End Sub