calculating the percentage of cells coloured green (1 Viewer)

dusty

Registered User.
Local time
Today, 13:27
Joined
Aug 20, 2009
Messages
42
I have a range of cells 6 columns 9 rows

which are either coloured red or green depending on the status of a task green completed red uncomplete. I want to be able to use a function/formula/macro to calculate the percentage of cells which are green.

Cheers Dusty
 

DCrake

Remembered
Local time
Today, 21:27
Joined
Jun 8, 2005
Messages
8,632
You will need an additional cell that queries the column using the same conditional formatting of the cells to sum them. Then use the result to create a percentage.

David
 

Brianwarnock

Retired
Local time
Today, 21:27
Joined
Jun 2, 2003
Messages
12,701
With a fixed area the function is quite simple

Code:
Public Function percentgreen() As Double
Dim count As Long

For Each c In Sheets("Sheet1").Range("A1:F9") ' name your correct Sheet and range
If c.Interior.ColorIndex = 3 Then                     ' You may have adifferent green than this 
       count = count + 1
End If
Next c
percentgreen = count * 100 / 54  ' you will want to apply rounding here
End Function

Brian
 

dusty

Registered User.
Local time
Today, 13:27
Joined
Aug 20, 2009
Messages
42
Thanks Brian works great

Also thanks Dcrake for your help.
 

Users who are viewing this thread

Top Bottom