Hello everyone, I have been using the below code successfully on a handful of worksheets. However, when I use this code on a number of worksheets, it takes a very very long time to complete. I was wondering if instead of utilizing the If .Name <> code, I could insert an array of worksheets that I would like this code to run on. Is that possible? I am looking to minimize the run time of the macro, and I believe using an array may help that. If anyone could help that would be great! Any other recommendations are welcome as well!!
Sub Detaildelete()
Dim LR As Long, I As Long, ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
With ws
If .Name <> "Details" And .Name <> "Summary" Then
LR = .Range("A" & .Rows.Count).End(xlUp).Row
For I = LR To 16 Step -1
If Trim(.Range("E" & I)) <> Trim(.Range("B8")) Or Trim(.Range("G" & I)) <> Trim(.Range("B9")) Or Trim(.Range("K" & I)) _
<> Trim(.Range("B10")) Or Trim(.Range("M" & I)) <> Trim(.Range("B11")) Then
.Rows(I).Delete
End If
Next I
End If
End With
Next ws
MsgBox "Complete"
End Sub
Bookmarks