LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Gan Gan is offline
external usenet poster
 
Posts: 2
Default Counting the number of rows based on the color

Hi,

Using Conditional Formatting, I color the cells in a column based on its
value. For Example : If the value is between 0 and 3 then I color the cell as
Green. If the value is between 3 and 4.5 then I color the cell as Yellow. If
the value is greater than 4.5 then I color the cell as Red. This was achieved
using Conditional Formatting. But now I want to count the number of Green,
Red and Yellow cells. For this I created a function to count the cells.

Function ColorFunction(rColor As Range, rRange As Range) As Long
Dim lCol As Long
Dim lActCol As Long
Dim lCount As Long
Dim rCell As Range
Application.Volatile True

lCol = rColor.Interior.ColorIndex

For Each rCell In rRange
lActCol = rCell.Interior.ColorIndex

If lCol = lActCol And rCell.Text < "" Then
lCount = lCount + 1
End If
Next
ColorFunction = lCount
End Function

But some how with conditional formatting the function is not working as the
Interior.ColorIndex is not matching with the rColor cell's ColorIndex.

Is there anyway that I can do to get the count based on the color rather
than doing it manually? If I color the cells manually without conditional
formatting then the function works fine without any problem, but when I
format the cells using conditional formatting it doesn't work.

Thanks,
Gan
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting rows based on the contents of multiple cells Bret[_2_] Excel Worksheet Functions 2 August 11th 09 09:26 PM
Delete Rows Based on highlighted Color Neon520 Excel Discussion (Misc queries) 7 March 28th 09 08:56 AM
Counting rows based on multiple columns Doyle Excel Worksheet Functions 1 September 29th 06 07:06 PM
counting based ona number of variables. vipa2000 Excel Worksheet Functions 11 July 29th 05 04:08 PM
Counting rows based on criteria in multiple cells Margaret Excel Discussion (Misc queries) 11 December 2nd 04 11:04 PM


All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"