How to sum cells filled with colour?

arapone

New Member
Joined
May 3, 2006
Messages
34
How is it possible to Count the number of cells which are filled with any color in a particular row using excel 2010?

I am not too familiar with VBA, so if i need to use it, please help me out with some instructions.

Thanks in advance.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Yes they are maunally colored, however the link only shows to count based on a colour reference to a specific cell. I am looking to count all colours together (sum of all cells in a row which are colored. Note the row has various colours).

Also i note that with VBA the function will not auto update if the contents are changed, unless the formula is re-entered or chanted. is there a possibility of doing this outside of VBA?
 
Upvote 0
Try this: press F9 to update

Code:
Function CountColor(r As Range) As Long
Application.Volatile
Dim c As Range
For Each c In r
    If c.Interior.ColorIndex <> xlNone Then CountColor = CountColor + 1
Next c
End Function
 
Upvote 0
Try this: press F9 to update

Code:
Function CountColor(r As Range) As Long
Application.Volatile
Dim c As Range
For Each c In r
    If c.Interior.ColorIndex <> xlNone Then CountColor = CountColor + 1
Next c
End Function

This works perfect. Thanks!
 
Upvote 0
I have another question,

How is it possible to use this function to create a sum at the bottom of each columm, however I want each true count to be multiplied by the number in column D for that particular row.

<a href="http://www.flickr.com/photos/23463579@N07/5529490481/" title="excel doc by fouselli, on Flickr"><img src="http://farm6.static.flickr.com/5059/5529490481_9645779f2e.jpg" width="399" height="306" alt="excel doc" /></a>

For example, the sum of Column E should return 30 and the sum of column J is 24, Sum of column K is 29, etc.
 
Upvote 0
I have a formula which checks a colum everytime a cell is highlighted and produces a sum of the total number of highlighted cells in the column.

=IF(CountColour(AC9:AC84)>0,CountColour(AC9:AC84),"")


What I would like the formula to do is everytime a cell is highlighted, take that cell and multiply it by a number in column A. The sum of all these instances should be displayed.

I.e. (x denotes a highlighted cell)

AC9 = 5 .... B9 = x
AC10 = 6 .... B10 =
AC11 = 2 .... B11 = x

Result 7


Any suggestions?
 
Last edited:
Upvote 0
I have applied the color function into VBA, but it isn't recognizing conditional fill coloring of the cells in question.... what can be done to remedy this?
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,794
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top