Deletion of rows according to background color

S

salim

I have an excelsheet wherby rows having different
background colors. How can i select certain background
color and delet the remaining.
Thanks
 
B

Bob Phillips

Salim,

You could do it this way

write a UDF to determine the ColoIndex of a cell
in the adjacent column, use the UDF to get the Colorindex
filter on this column
select not equal to hour value
Delet visible rows

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

Tom Ogilvy

Here is an additional approach:
assume the colors are at least in column A

Sub DeleteColor()
Dim rng As Range, LastRow As Long
Dim i As Long
Set rng = ActiveSheet.UsedRange.Columns(1).Cells
LastRow = rng(rng.Count).Row
For i = LastRow To 1 Step -1
idex = Cells(i, 1).Interior.ColorIndex
Select Case idex
Case 3, 8, 9, 21
Cells(i, 1).EntireRow.Delete
End Select
Next
End Sub
 
Top