下面的代码删除不符合我的条件的行。当我的行数超过 1,68,000 时,大约需要 52 分钟,而且这将继续增加。
我正在使用过滤器来减少数据。这不再是一个选择。我必须根据我的日期比较范围删除行。似乎数组是我最后的手段,但我不知道如何将我的工作表存储在数组中并对其进行处理。
如何将我的工作表存储在一个数组中并进行处理?
' to delete data not meeting criteria
Worksheets("Dashboard").Activate
n1 = Range("n1")
n2 = Range("n2")
Worksheets("Temp Calc").Activate
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For z = lastrow To 2 Step -1
If Cells(z, 6).Value = "CNF" Or Cells(z, 4).Value <= n1 Or Cells(z,3).Value >= n2 Then
Rows(z).Delete
End If
Next z
这是基本的东西。
Dim arr1(), dim arr2() as variant
lastrow = cells(Rows.count,1).End(XlUp).Row
lastcol = cells(1,column.count).End(xlRight).Column
arr1(lastrow,lastcol) <- I dont know if this is correct.
<------How do I copy/paste my data into the array? ----->
<This is what I came up with for deleting what I dont need.>
For x=lastrow to 2 Step -1
If arr1(x,6)<>"" or arr1(x,6)<>"CNF" And arr(x,4)>=n1 And arr(x,3)<=n2 then
For k = lastrow to 2
<I dont know how to delete rows in an array.
rows(x).delete ?