View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
pikus pikus is offline
external usenet poster
 
Posts: 1
Default Contional Row Delete on Interior Color

Alright Newb,
Here’s the deal. With “UsedRange.Rows.Count” you can only count on i
giving you the correct result if there are no empty rows at the top o
your worksheet. Instead, use this:

.UsedRange.Row - 1 + .UsedRange.Rows.Count

That will always work.

So try this, but be sure to change the "10" in "For c = 1 To 10" t
the number of columns you're concerned with:
With Worksheets(“Jobs”)
x = .UsedRange.Row - 1 + .UsedRange.Rows.Count
For r = x To 2 Step -1
keep = False
For c = 1 To 10
If .Cells(r, c).Interior.ColorIndex = 6 Then
keep = True
End If
Next c
If keep = False Then
.Rows(r).Delete
End If
Next r
End Wit

--
Message posted from http://www.ExcelForum.com