Filter by color

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

Guest

Hi,

I have a large spreadsheet. Many of the cells are highlighted with different
colors. I want to filter the database according to color like select the
cells with red background color only.
Is it possible?
Thank You in advance.


Regards,
Pawan
 
Pawan said:
I have a large spreadsheet. Many of the cells are highlighted with different
colors. I want to filter the database according to color like select the
cells with red background color only.
Is it possible?

In place filtering can be a bit complex to achieve, an easier way is to copy
the values to another worksheet. For example if you have two columns of data
and you want to extract the rows where cells in col 2 have red background
color.

Private Sub CommandButton1_Click()
Dim j As Integer, row As Integer
row = 1
For j = 1 To 100
If Cells(j, 2).Interior.Color = vbRed Then
Worksheets("Sheet2").Cells(row, 1).Formula = Cells(j, 1).Formula
Worksheets("Sheet2").Cells(row, 2).Formula = Cells(j, 2).Formula
row = row + 1
End If
Next j
End Sub
 
You could try adding a new column, using a UDF to populate the values.

Eg:

Function GetColor(c)
GetColor=c.interior.colorindex
End Function

Then filter on the new column

Tim.
 
Hi Pawan,

Depending on your data configuration, you may be able to add a helper column
and use a function, provided by Chip Pearson, to return the background
colour. You could then filter on the helper column.

See Chip Pearson's 'Sorting By Color' page at:

http://www.cpearson.com/excel/SortByColor.htm

See particulatly Chip's ColorIndexOfCell function.
 

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