我将挑战潜在的假设,即AutoFilter是快速前进的方法 - 通常很难在变量数组上击败循环
这个演示展示了一种方法,在我的系统上处理8000多行,在亚秒内删除半个运行
Sub DEMO() Dim datrng As Range Dim dat, newdat Dim i As Long, j As Long, k As Long With ThisWorkbook.Worksheets("Upload") Set datrng = .Range(.Cells(1, 1), .Cells(.Rows.Count, "S").End(xlUp)) End With dat = datrng.Value ReDim newdat(1 To UBound(dat, 1), 1 To UBound(dat, 2)) j = 1 For i = 1 To UBound(dat, 1) If dat(i, 19) <> 0 Then ' test for items you want to keep For k = 1 To UBound(dat, 2) newdat(j, k) = dat(i, k) Next j = j + 1 End If Next datrng = newdat End Sub