Is there a function which can sum up all the cells in a column where the
contents of the cell are in pink color.
Pls help.
Thanks
Is there a function which can sum up all the cells in a column where the
contents of the cell are in pink color.
Pls help.
Thanks
try:
Function SumByFontColor(ColorNum)
set rng = ActiveSheet.UsedRange.rows
For each c in rng
If c.font.colorindex=ColorNum then
s = s + c.value
End if
SumByColorFont= s
End Function
try:
Function SumByFontColor(ColorNum)
Set rng = ActiveSheet.UsedRange.Rows
rng.Select
For Each c In Selection
If c.Font.ColorIndex = ColorNum Then
s = s + c.Value
MsgBox s
End If
Next
SumByFontColor = s
End Function
something along these lines to get you started:
Option Explicit
Enum eColor
Pink = 13408767
End Enum
Function ColorSum(Source As Range) As Double
Dim total As Double
Dim cell As Range
For Each cell In Source
With cell
If .Font.Color = eColor.Pink Then
total = total + .Value
End If
End With
Next
ColorSum = total
End Function
Enhancements:
1) see if you can make the color a parameter
2) add a check to ensure that a cell has a legitimate value befor totalling
works as is though.
"mario" wrote:
> Is there a function which can sum up all the cells in a column where the
> contents of the cell are in pink color.
>
> Pls help.
>
> Thanks
See http://www.xldynamic.com/source/xld.ColourCounter.html
--
HTH
RP
(remove nothere from the email address if mailing direct)
"mario" <[email protected]> wrote in message
news:[email protected]...
> Is there a function which can sum up all the cells in a column where the
> contents of the cell are in pink color.
>
> Pls help.
>
> Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks