View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Vacuum Sealed Vacuum Sealed is offline
external usenet poster
 
Posts: 259
Default How many rows are coloured

On 12/03/2012 5:22 AM, Moideen wrote:
Hai,

Please help me to get count rows of coloured.

Data Having 125 Rows, Row No : 50 and Row No : 75 are coloured with
blue

Need MSG on Row1 "2 Rows are colored" is there any function in excel
2007 for this.





Hi

There is most likely a better code out there, I have seen one, just
can't locate it, that said! I have tested the below and it does the job
well ( assuming you are using the standard Blue = 12611584 ).

Record a Macro and change a cell to your desired color and change the
code to reflect.

Sub CountColor()

Dim tCell As Range 'Total colored Cells
Dim hRng As Range 'Helper Count Range
Dim myRng As Range 'Range of Column A
Dim c As Range

Set tCell = [A1] 'Displays Total color Cells
Set hRng = Range("B2:B10") '**Change Range to suit
Set myRng = Range("A2:A10") 'Change Range to suit

For Each c In myRng
If c.Interior.Color = 12611584 Then
c.Offset(0, 1).Value = 1 '**Change number of Columns to offset
End If
Next c

tCell = WorksheetFunction.Sum(hRng) & " Cells are Colored"

End Sub

HTH
Mick.