Count formated cells

B

bobtracey

I would like to count the number of cells in a column that have been
formatted a certain colour. is this possible?
 
B

Bernie Deitrick

Bob,

It is using a User-Defined-Function:

Function CountFormat(inRange As Range, CI As Integer) As Integer
Dim myCell As Range
For Each myCell In Intersect(inRange.Parent.UsedRange, inRange)
If myCell.Interior.ColorIndex = CI Then
CountFormat = CountFormat + 1
End If
Next myCell
End Function

Used like

=CountFormat(A:A,6)

to count all the bright yellow cells in column A.

You can determine the proper colorindex by recording a macro where you apply
that color to a cell.

HTH,
Bernie
MS Excel MVP
 

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

Top