Hi.
I need a method that delete rows that contains a string ("class" in my case)
the problem is that this code is slow. i need to run it on 15 sheets at least.
Is there a faster way to do this ?
Thanks
Here is my code:
PHP Code:
Sub DeleteEmptyRows(wsheet As Worksheet)
Dim calcmode As Long
Dim ViewMode As Long
Dim myStrings As Variant
Dim FoundCell As Range
Dim I As Long
Dim myRng As Range
Dim sh As Worksheet
With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With wsheet
Set myRng = .Range(.Cells(1, 1), .Cells(wsheet.UsedRange.Rows.Count,7))
End With
'Add more search strings if you need
myStrings = Array("class")
With myRng
For I = LBound(myStrings) To UBound(myStrings)
Do
Set FoundCell = myRng.Find(What:=myStrings(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
Loop
Next I
End With
End Sub
Bookmarks