ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding cells in a range based on format color (https://www.excelbanter.com/excel-programming/278334-adding-cells-range-based-format-color.html)

Mo[_4_]

Adding cells in a range based on format color
 
Would anyone like to tell me how it would be possible to add only the cells
that are colored e.g. red through a range

Mo



merjet

Adding cells in a range based on format color
 
Would anyone like to tell me how it would be possible to
add only the cells that are colored e.g. red through a range


Function SumRed(Target As Range) As Integer
Dim c As Range

For Each c In Target
If c.Interior.ColorIndex = 3 Then SumRed = SumRed + 1
Next c
End Function

HTH,
Merjet



Chip Pearson

Adding cells in a range based on format color
 
Mo,
You need to use a VBA procedure to do this. See the SumByColor function at
www.cpearson.com/excel/colors.htm .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"Mo" wrote in message
...
Would anyone like to tell me how it would be possible to add only the

cells
that are colored e.g. red through a range

Mo





merjet

Adding cells in a range based on format color
 
If c.Interior.ColorIndex = 3 Then SumRed = SumRed + 1
That should have been:
If c.Interior.ColorIndex = 3 Then SumRed = SumRed + c

Merjet



Mo Childs

Adding cells in a range based on format color
 
Thanks to Chip & merjet for the help


"Mo" wrote in message
...
Would anyone like to tell me how it would be possible to add only the

cells
that are colored e.g. red through a range

Mo






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

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