View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
moon[_5_] moon[_5_] is offline
external usenet poster
 
Posts: 40
Default need to delete all rows that are gray


If Selection.Interior.ColorIndex = Gray Then EntireRow.Delete

or (when there's more to do):

If Selection.Interior.ColorIndex = Gray Then
EntireRow.Delete
End If

You just forgot the 'then', that's all.



"Janis" schreef in bericht
...
Sub deleteColoredRows()

Const Gray = 15
Range("A1").EntireRow.Select
Do While ActiveCell.Value < ""
if Selection.Interior.ColorIndex = Gray
EntireRow.Delete
End If
Loop

End Sub

assuming I have the right color index number, how do I correct the
if/then
line
so I can delete all rows that are gray? there is an error on the delete
and
if/then lines

thanks,