Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default How to calculate a coloured cell as a number for a sum?

I have a chart and want to know how I can get the sum of coloured cell? Is
there a macro or a function where I can do that?

i.e

I have Cells C3:R3 and (cells E3, H3, I3,J3 and N3 is coloured ) I want S3
to show the total (5)

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default How to calculate a coloured cell as a number for a sum?

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


"Atomic" wrote:

I have a chart and want to know how I can get the sum of coloured cell? Is
there a macro or a function where I can do that?

i.e

I have Cells C3:R3 and (cells E3, H3, I3,J3 and N3 is coloured ) I want S3
to show the total (5)

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default How to calculate a coloured cell as a number for a sum?

Hi,

in Excel 2007, you can filter the column by colour and then use the
SUBTOTAL(9,range) function. This will sum up the coloured cells.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Atomic" wrote in message
...
I have a chart and want to know how I can get the sum of coloured cell? Is
there a macro or a function where I can do that?

i.e

I have Cells C3:R3 and (cells E3, H3, I3,J3 and N3 is coloured ) I want S3
to show the total (5)

Thank you


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
Calculate the number of hours in a date/time cell richardwo Excel Worksheet Functions 1 April 16th 09 11:48 AM
Calculate the number of weeksdays based on a cell value [email protected] Excel Worksheet Functions 10 January 8th 09 05:18 PM
Summing the number of paticular coloured cells gazoom Excel Discussion (Misc queries) 1 May 19th 08 08:39 AM
calculate using last four digits of number in cell Andy Falkner Excel Worksheet Functions 3 February 10th 06 05:30 PM
how do i sought coloured number cells from normal ones? sjb1981 Excel Discussion (Misc queries) 1 April 1st 05 02:49 PM


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

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"