It isn't clear what you want. Do you want to test only cells in rows
10 to 15 and 100 to 200 and delete those rows that are not green? In
this case, use code like
Sub AAA()
Dim RowNum As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
On Error GoTo ErrH:
For RowNum = 200 To 100 Step -1
If Cells(RowNum, "A").Interior.ColorIndex <> 4 Then
' not green -- delete.
Rows(RowNum).Delete shift:=xlShiftUp
End If
Next RowNum
For RowNum = 15 To 10 Step -1
If Cells(RowNum, "A").Interior.ColorIndex <> 4 Then
' not green -- delete.
Rows(RowNum).Delete shift:=xlShiftUp
End If
Next RowNum
ErrH:
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
If you want to delete ALL rows that are not green from 1 to 200, use
Sub BBB()
Dim RowNum As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
On Error GoTo ErrH:
For RowNum = 200 To 1 Step -1
If Cells(RowNum, "A").Interior.ColorIndex <> 4 Then
Rows(RowNum).Delete shift:=xlShiftUp
End If
Next RowNum
ErrH:
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
If you have something else in mind, you can modify either of the
following to meet your needs. The key here is that you want to
deletions to go from the bottom up -- highest row number to lowest row
number. Otherwise, you'll skip some rows.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)