Попробуйте использовать объединение для скорости
Sub Delete_Rows_Using_Loops()
Dim ws As Worksheet, r As Long, c As Range
Application.ScreenUpdating = False
Application.Calculation = xlManual
Set ws = ThisWorkbook.Sheets("Sheet1")
For r = ws.UsedRange.Rows.Count To 3 Step -1
If ws.Cells(r, 7).Value = 0 And ws.Cells(r, 9).Value = 0 Then
If c Is Nothing Then Set c = ws.Rows(r) Else Set c = Union(c, ws.Rows(r))
End If
Next r
If Not c Is Nothing Then c.Delete
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
MsgBox "Finished", 64
End Sub
Другим более быстрым подходом является использование автофильтра. Предположим, что заголовки в строке 2
Sub Delete_Rows_Using_AutoFilter()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlManual
Set ws = ThisWorkbook.Worksheets("Sheet1")
With ws.Range("G2:I" & ws.Cells(Rows.Count, 7).End(xlUp).Row)
.AutoFilter 1, "="
.AutoFilter 3, "="
If .Columns(1).SpecialCells(12).Count > 1 Then
.Offset(1).Resize(.Rows.Count - 1).Delete xlShiftUp
End If
.AutoFilter
End With
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
MsgBox "Finished", 64
End Sub
И вот третий подход, использующий Evaluate для получения удаляемых строк
Sub Delete_Rows_Using_Evaluate()
Dim x, ws As Worksheet, r As Range
Application.ScreenUpdating = False
Application.Calculation = xlManual
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
Set r = .Range("G3:G" & .Cells(Rows.Count, 7).End(xlUp).Row)
x = Filter(.Evaluate("TRANSPOSE(IF((" & r.Address & "=0)+(" & r.Offset(, 2).Address & "=0),""A"" & ROW(" & r.Address & ")))"), False, False)
If UBound(x) = -1 Then Exit Sub
.Range(Join(x, ",")).EntireRow.Delete
End With
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub