filter cells by text font color

orit

New Member
Joined
Oct 31, 2004
Messages
44
I have a large worksheet which I would like to filter according the color of the font of the text written in each cell. I want that by clicking a button, only the rows where the color of the text in specific column is blue will be displayed, by clicking another button, only the rows with the red text will be displayed etc..., how suppose to be macro for that?

Thanks a lot
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
something like:
Code:
For Each cell In Range("A1:B10")

  If cell.Font.ColorIndex = 2 Then

    cell.EntireRow.Hidden = True
    
  End If

Next cell
this will hide the rows in which the colored text appears.
 
Upvote 0
Thanks much,

I have various font colors in the worksheet... If possible, is there a way to define which color to show (instead of which color to hide)?
if not, what is the syntax for hiding multiple colors?

another thing, is it possible that it will work on all the content of the sheet instead of defining a range?

Thanks again
 
Upvote 0
Code:
For Each cell In Range("A1:B10")

  If cell.Font.ColorIndex <> mycolor Then

    cell.EntireRow.Hidden = True
   
  Else

    cell.EntireRow.Hidden = False

  End If

Next cell

where my color is the color you want to show.
I added some code to make hidden rows visible again, because you might want to run this code multiple times in a row I think.
 
Upvote 0
does the number correspond with the color that you want to make visible? You can see this by using this code:

Code:
Sub x()
    MsgBox (Range("A1").Font.ColorIndex)
End Sub

and pressing F5
 
Upvote 0
sorry, the range I used is not correct. It would look for both the cells in column a an b to have the right color. change it to this:
Code:
For Each cell In Range("A1:A10")

  If cell.Font.ColorIndex <> mycolor Then

    cell.EntireRow.Hidden = True
   
  Else

    cell.EntireRow.Hidden = False

  End If

Next cell
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top