Deletion of rows according to background color

  • Thread starter Thread starter salim
  • Start date Start date
S

salim

I have an excelsheet wherby rows having different
background colors. How can i select certain background
color and delet the remaining.
Thanks
 
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)
 
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
 

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