Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count formats

Status
Not open for further replies.

grendal

MIS
Sep 30, 2001
35
GB
I know how to count the number of cells in a range that contain a letter. But, is it possible to count the number of cells in a range that are formatted, say, yellow?

 
To do this you will need to program a custom function, unless you are using COnditional Formatting to get the specific format. In this case you can just count the values that cause a cell to change yellow.



[santa] Happy Ho Ho!!! [Cheers]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Hi,

The following code counts up all the cells in all the worksheet that are coloured Yellow.

Code:
Public Sub ShowCount()

    Debug.Print CountUp

End Sub

Public Function CountUp() As Long

Dim rng As Range
Dim sht As Worksheet

    For Each sht In ActiveWorkbook.Sheets
    
        For Each rng In ActiveSheet.Cells
        
        rng.Select
        
            If Selection.Interior.ColorIndex = 6 Then
            
                CountUp = CountUp + 1
                DoEvents
                Debug.Print CountUp
            
            End If
            
        Next
    
    Next

End Function

Hope this helps.


Leigh Moore
Solutions 4 MS Office Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top