Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default add value of cells based on the formatted fill color

Can excel count values in a range of cells based on the fill color?
(for example you only want it to count the ones that have the fill
color red. Not count the number of red cells but count the values in the
cells)
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default add value of cells based on the formatted fill color

There is no built-in excel function to do this. But you can use a UDF that
looks at the range and returns the sum of color. But that function will not
recalculate if you change color. Every time you change the color you will
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

=colorsum(A5:A9,D5)
cell D5 will have the fill color which is the query color...to be searched
in the range A5:A9

'To count the number of cells with numeric values
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then
If IsNumeric(cell.Text) Then ColorSum = ColorSum + 1
End If
Next
End Function


'If you mean to sum the cell values with matching color then
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then
ColorSum = ColorSum + cell.Value
End If
Next
End Function


If this post helps click Yes
---------------
Jacob Skaria


"mike" wrote:

Can excel count values in a range of cells based on the fill color?
(for example you only want it to count the ones that have the fill
color red. Not count the number of red cells but count the values in the
cells)

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default add value of cells based on the formatted fill color

Hi,

If you are using Excel 2007, then you can filter based on colour and then
use the SUBTOTAL(9,range) function.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"mike" wrote in message
...
Can excel count values in a range of cells based on the fill color?
(for example you only want it to count the ones that have the fill
color red. Not count the number of red cells but count the values in the
cells)


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 136
Default add value of cells based on the formatted fill color

It should be


SUBTOTAL(3,range)


or


SUBTOTAL(2,range)


for counting, 9 will sum the values

--


Regards,


Peo Sjoblom


"Ashish Mathur" wrote in message
...
Hi,

If you are using Excel 2007, then you can filter based on colour and then
use the SUBTOTAL(9,range) function.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"mike" wrote in message
...
Can excel count values in a range of cells based on the fill color?
(for example you only want it to count the ones that have the fill
color red. Not count the number of red cells but count the values in the
cells)




Reply
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
Summing cells within a column based on cell fill color Jim D. New Users to Excel 2 October 8th 08 04:56 PM
make all cells in same row match cell formatted with fill color zjopa Excel Discussion (Misc queries) 2 May 21st 08 04:26 AM
Is there a way to count cells in a range based on fill color? eehinmd Excel Worksheet Functions 2 March 16th 06 05:09 PM
Fill cells with color based on criteria in two cells AA Excel Worksheet Functions 2 January 2nd 06 11:29 PM
color fill cells based on IF function or formula Victor Jones Excel Worksheet Functions 1 November 23rd 05 03:17 PM


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

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

About Us

"It's about Microsoft Excel"