need to delete all rows that are gray

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top