View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JeanPierre Charron JeanPierre Charron is offline
external usenet poster
 
Posts: 24
Default Deleting Rows on condition & Long processing time

Problem # 1 : Delete Rows where
Col "A" Cells are < "F1PP601
Row 1 Col A Col B
Row 2 F601 AWP
Row 3 F1PPM60602 AW2
Row 4 F1PPM60601 AWP
Row 5 F1PPM60601 AW3
Row 6 F1PPM60603 AW2
Row 7 F1PPM60602 AW1
Row 8 F1PPM60601 AW$
..
Sub DeleteRows()
Dim strCheck As String
Dim LRow As Long, i As Long
Dim varData As Variant

With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

strCheck = "F1PPM60601,F1PPM60602"

With Sheets("PM4")
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
varData = .Range("P2:P" & LRow)
For i = UBound(varData) To LBound(varData) Step -1
If InStr(strCheck, varData(i, 1)) = 0 Then
Rows(i + 1).Delete
End If
Next
End With
With Sheets("PM4")
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
varData = .Range("BE2:BE" & LRow)
For i = UBound(varData) To LBound(varData) Step -1
With .Cells(i, "BE")
If Not IsError(.Value) Then
If .Value = "AWP" Then .EntireRow.Delete
End If
End With
Next
End With
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub