我的工作簿中有幾個宏。這是唯一一個在2500排工作表上似乎很慢3-5分鐘的人。刪除行時進程緩慢 - 如何使速度更快?
目的是如果行在日期dtFrom和dtUpTo之間然後刪除整行。
我加入到暫停和恢復計算,提振稍微
人對如何使這個更快的任何想法?
Sub DeleteRows
'--- Pause Calculations:
Application.Calculation = xlManual
'----- DELETE ROWS -----
Dim dtFrom As Date
Dim dtUpto As Date
Dim y As Long
Dim vCont As Variant
dtFrom = Sheets("Control Panel").Range("D5").Value
dtUpto = dtFrom + 6
Sheet1.Range("D1").Value2 = "Scanning, Please wait..."
With Sheets("Database")
For y = Sheet5.Cells(Sheet5.Rows.Count, 2).End(xlUp).Row + 1 To 2 Step -1
vCont = .Cells(y, 1).Value
If Not IsError(vCont) Then
If vCont >= dtFrom And vCont <= dtUpto Then
.Rows(y).EntireRow.Delete
End If
End If
Next
End With
'--- Resume Calculations:
Application.Calculation = xlAutomatic
End Sub
謝謝!
UNION-DELETE技術是加快速度的好方法。 http://stackoverflow.com/a/34564306/4288101 –