#1   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default counting by color

I have followed instruvtions to count by color but when I insert the function
an error message comes up "takes no arguments'
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,510
Default counting by color

Post an example of the formula you have attempted to create.

--
Regards,

OssieMac


"cc" wrote:

I have followed instruvtions to count by color but when I insert the function
an error message comes up "takes no arguments'

  #3   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default counting by color

Function SumByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Double
'
' This function return the SUM of the values of cells in
' InRange with a background color, or if OfText is True a
' font color, equal to WhatColorIndex.
'
Dim Rng As Range
Dim OK As Boolean

Application.Volatile True
For Each Rng In InRange.Cells
If OfText = True Then
OK = (Rng.Font.ColorIndex = WhatColorIndex)
Else
OK = (Rng.Interior.ColorIndex = WhatColorIndex)
End If
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng

End Function




"OssieMac" wrote:

Post an example of the formula you have attempted to create.

--
Regards,

OssieMac


"cc" wrote:

I have followed instruvtions to count by color but when I insert the function
an error message comes up "takes no arguments'

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,510
Default counting by color

The function works.

For background (or interior color) red which is colorindex 3, you need to
enter the formula as:-
=SumByColor(A1:A14,3,FALSE)

The FALSE is optional when summing by background. You could use:-
=SumByColor(A1:A14,3)


For font color yellow which is colorindex 6, the formula is a follows:-
=SumByColor(A1:A14,6,TRUE). (TRUE is not optional here because that is what
tells the system that it is the font color and not the background color to
look for.


--
Regards,

OssieMac


"cc" wrote:

Function SumByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Double
'
' This function return the SUM of the values of cells in
' InRange with a background color, or if OfText is True a
' font color, equal to WhatColorIndex.
'
Dim Rng As Range
Dim OK As Boolean

Application.Volatile True
For Each Rng In InRange.Cells
If OfText = True Then
OK = (Rng.Font.ColorIndex = WhatColorIndex)
Else
OK = (Rng.Interior.ColorIndex = WhatColorIndex)
End If
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng

End Function




"OssieMac" wrote:

Post an example of the formula you have attempted to create.

--
Regards,

OssieMac


"cc" wrote:

I have followed instruvtions to count by color but when I insert the function
an error message comes up "takes no arguments'

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default counting by color

One minor caveat -

This is really "SumByColorIndex", not SumByColor.

ColorIndex 3 in the default palette is red, and ColorIndex 6 in the
default palette is yellow

However, the color assignments may not hold true if the Color Palette
has been modified (e.g., manually, or by applying a different theme).

If one's users never change themes or color palette settings, that
shouldn't be a problem.



In article ,
OssieMac wrote:

The function works.

For background (or interior color) red which is colorindex 3, you need to
enter the formula as:-
=SumByColor(A1:A14,3,FALSE)

The FALSE is optional when summing by background. You could use:-
=SumByColor(A1:A14,3)


For font color yellow which is colorindex 6, the formula is a follows:-
=SumByColor(A1:A14,6,TRUE). (TRUE is not optional here because that is what
tells the system that it is the font color and not the background color to
look for.



  #6   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default counting by color

Thanks for your assistance I'm a beginner at this and still cant seem to get
it. I have inserted the following as I'm using yellow

=SUMBYCOLOR(DD4:DD19,6,TRUE)



"JE McGimpsey" wrote:

One minor caveat -

This is really "SumByColorIndex", not SumByColor.

ColorIndex 3 in the default palette is red, and ColorIndex 6 in the
default palette is yellow

However, the color assignments may not hold true if the Color Palette
has been modified (e.g., manually, or by applying a different theme).

If one's users never change themes or color palette settings, that
shouldn't be a problem.



In article ,
OssieMac wrote:

The function works.

For background (or interior color) red which is colorindex 3, you need to
enter the formula as:-
=SumByColor(A1:A14,3,FALSE)

The FALSE is optional when summing by background. You could use:-
=SumByColor(A1:A14,3)


For font color yellow which is colorindex 6, the formula is a follows:-
=SumByColor(A1:A14,6,TRUE). (TRUE is not optional here because that is what
tells the system that it is the font color and not the background color to
look for.


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default counting by color

That works for me for font color (after recalculating - just changing
the font color doesn't cause a recalc). You did intend font color (i.e.,
TRUE in the 3rd argument), right?

However, there are two "yellows" in the default Color Palette - the pale
one is ColorIndex 36.


In article ,
cc wrote:

Thanks for your assistance I'm a beginner at this and still cant seem to get
it. I have inserted the following as I'm using yellow

=SUMBYCOLOR(DD4:DD19,6,TRUE)

  #8   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default counting by color

I've got it, thanks for your help guys.


"JE McGimpsey" wrote:

That works for me for font color (after recalculating - just changing
the font color doesn't cause a recalc). You did intend font color (i.e.,
TRUE in the 3rd argument), right?

However, there are two "yellows" in the default Color Palette - the pale
one is ColorIndex 36.


In article ,
cc wrote:

Thanks for your assistance I'm a beginner at this and still cant seem to get
it. I have inserted the following as I'm using yellow

=SUMBYCOLOR(DD4:DD19,6,TRUE)


  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 449
Default counting by color

I've found it more user friendly to use "same color as this cell" instead of
hardcoding an obscure indexnumber, like

Function SumByColor(InRange As Range, SameColorAs As Range, _
Optional OfText As Boolean = False) As Double

Dim WhatColorIndex As Integer

If OfText = True then
WhatColorIndex = SameColorAs(1).Font.ColorIndex
Else
WhatColorIndex = SameColorAs(1).Interior.ColorIndex
....

(Haven't done this yet with 2007 though, so I'm not sure how it deals with
all variations of themes, pallettes and all that stuff, or if there's
another better approach.)

Best wishes Harald


"JE McGimpsey" wrote in message
...
One minor caveat -

This is really "SumByColorIndex", not SumByColor.

ColorIndex 3 in the default palette is red, and ColorIndex 6 in the
default palette is yellow

However, the color assignments may not hold true if the Color Palette
has been modified (e.g., manually, or by applying a different theme).

If one's users never change themes or color palette settings, that
shouldn't be a problem.



In article ,
OssieMac wrote:

The function works.

For background (or interior color) red which is colorindex 3, you need to
enter the formula as:-
=SumByColor(A1:A14,3,FALSE)

The FALSE is optional when summing by background. You could use:-
=SumByColor(A1:A14,3)


For font color yellow which is colorindex 6, the formula is a follows:-
=SumByColor(A1:A14,6,TRUE). (TRUE is not optional here because that is
what
tells the system that it is the font color and not the background color
to
look for.


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
counting cell by color and condition Mark Excel Discussion (Misc queries) 1 April 22nd 07 04:56 PM
counting cells by text color alberto Excel Worksheet Functions 6 April 6th 07 11:54 PM
Counting Conditional Filtered (By Color) Cells carl Excel Worksheet Functions 4 April 8th 06 12:09 AM
counting cell color help darkbearpooh1 Excel Worksheet Functions 4 January 25th 06 02:59 AM
Counting entries by color code Carmen Excel Discussion (Misc queries) 3 September 19th 05 09:45 PM


All times are GMT +1. The time now is 01:04 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"