ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Adding ONLY cells of certain color (https://www.excelbanter.com/excel-discussion-misc-queries/70360-adding-only-cells-certain-color.html)

Kentucky Insurance

Adding ONLY cells of certain color
 
Hello!
Can anyone tell me how to add only cells of a certain color? Whether it's
the cell's background color, or the font color, doesn't really matter. I
researched and seemed like SumIF was the correct function, but I can't figure
out how to specify only certain colors.....
Thanks for your help.

Bernard Liengme

Adding ONLY cells of certain color
 
Visit Chip at http://www.cpearson.com/excel/colors.htm

--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Kentucky Insurance" wrote in
message ...
Hello!
Can anyone tell me how to add only cells of a certain color? Whether it's
the cell's background color, or the font color, doesn't really matter. I
researched and seemed like SumIF was the correct function, but I can't
figure
out how to specify only certain colors.....
Thanks for your help.




Gary''s Student

Adding ONLY cells of certain color
 
Enter this UDF:

Function SumRed(r As Range) As Long
Dim rr As Range
SumRed = 0
For Each rr In r
If rr.Interior.ColorIndex = 3 Then
SumRed = SumRed + rr.Value
End If
Next
End Function

and use it like:
=SumRed(A1:G4)

It will sum those cells that have a red background. If you change the
cell's background after you have entered the formula, you will need to
manually re-calculate the worksheet:

CNTRL-ALT-F9
--
Gary''s Student


"Kentucky Insurance" wrote:

Hello!
Can anyone tell me how to add only cells of a certain color? Whether it's
the cell's background color, or the font color, doesn't really matter. I
researched and seemed like SumIF was the correct function, but I can't figure
out how to specify only certain colors.....
Thanks for your help.



All times are GMT +1. The time now is 09:20 PM.

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