Ask Experts Questions for FREE Help !
Ask
    Mearon's Avatar
    Mearon Posts: 1, Reputation: 1
    New Member
     
    #1

    Feb 7, 2007, 01:00 PM
    How to count cells with colored font.
    I'm have a spread sheet in Excel that has some cells fonts in red to indicate poor numbers. I want to know how I can count how many cells on the spread sheet have red font. I tried to do a COUNTIF command but I'm not sure if this is will count the colored font data.
    l99057j's Avatar
    l99057j Posts: 57, Reputation: 18
    Junior Member
     
    #2

    Feb 12, 2007, 04:23 PM
    Google the following:

    Count excel cells color

    The first link that comes up is dead, but if you click on the Cached version you'll see it. It should be simple to modify this to use the foreground color rather than the background.
    nikeshtnt's Avatar
    nikeshtnt Posts: 52, Reputation: 1
    Junior Member
     
    #3

    Aug 15, 2008, 05:21 AM
    You can use the following macro and formula for this.

    Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)

    Dim rCell As Range

    Dim lCol As Long

    Dim vResult



    ''''''''''''''''''''''''''''''''''''''

    'Written by Ozgrid Business Applications

    'www.ozgrid.com



    'Sums or counts cells based on a specified fill color.

    '''''''''''''''''''''''''''''''''''''''



    lCol = rColor.Interior.ColorIndex



    If SUM = True Then

    For Each rCell In rRange

    If rCell.Interior.ColorIndex = lCol Then

    vResult = WorksheetFunction.SUM(rCell,vResult)

    End If

    Next rCell

    Else

    For Each rCell In rRange

    If rCell.Interior.ColorIndex = lCol Then

    vResult = 1 + vResult

    End If

    Next rCell

    End If



    ColorFunction = vResult

    End Function

    --------------------------------------------------------------------------------

    You can now use the custom function (ColorFunction) like;

    =ColorFunction($C$1,$A$1:$A$12,TRUE) to SUM the values in range of cells $A$1:$A$12 that have the same fill color as cell $C$1. The reason it will SUM in this example is because we have used TRUE as the last argument for the custom function.

    To COUNT these cells that have the same fill color as cell $C$1 you could use:

    =ColorFunction($C$1,$A$1:$A$12,FALSE) or =ColorFunction($C$1,$A$1:$A$12) by omitting the last argument our function will automatically default to using FALSE.

    Be aware that the changing of a cells fill color will not cause the Custom Function to recalculate, even if you press F9 (Recalculates the whole Workbook). You will need to either, select the cell and re-enter the formula, or go to Edit>Replace and replace = with =, or use Ctrl+Alt+F9

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Colored Flame Candle [ 1 Answers ]

How to get colored flame from liquid fuel ?

Another Count Question [ 1 Answers ]

I have a Spread sheet which links to my Database. This sheet querys the database and puts everything in a what we call a "TAM" number order. (example D1158 , D1159 , D1125). All of these numbers are shown in Column A. Is there a way I can set a cell to count the number of D1158's there are? I have...

Orange colored hair [ 1 Answers ]

My daughter got her hair color darkened a few months ago. However, now it is looking very dry and has an orange hue to it. She is a swimmer and had just begun swimming practice daily, so she gets exposed to chlorine everyday. Is there anything we can do for her hair to get that orange cast off...

Clicking differnet cells and it selecting all cells [ 2 Answers ]

Just wondered if anyone knew what I did to get ms excel to select all cells from A1 to what ever cell I clicked on. Thought it was sticky keys but it was turned off. Clicked left mouse button and it moved cells then when I clicked other cells it started using that as a new ref point and selecting...

Different Colored Filenames [ 3 Answers ]

Ok, this is probably so obvious, and this is definitely something I should know with how much I work on computers... but here it is... In my folders and drives some of the file names are blue, but most are black... Why are my file names suddenly blue? I am running Windows XP Home...


View more questions Search