ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum based on font color (https://www.excelbanter.com/excel-programming/327693-sum-based-font-color.html)

mario

Sum based on font color
 
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

Patrick Molloy[_2_]

Sum based on font color
 
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


Bob Phillips[_6_]

Sum based on font color
 
See http://www.xldynamic.com/source/xld.ColourCounter.html

--

HTH

RP
(remove nothere from the email address if mailing direct)


"mario" wrote in message
...
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





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com