• 470K Members
• 5,811 Online
• 568K Conversations

New Contributor

# How do I add cells with the same background color?

`How do I add cells with the same background color?`
3 Replies

# Re: How do I add cells with the same background color?

Hello @jmbcb,

You may use a filter to filter the cells with the same background color and subtotal the column to total the cells with the same background color.

Hope this helps!
PReagan

# Re: How do I add cells with the same background color?

what I'm trying to add is

# Re: How do I add cells with the same background color?

Here is one possible way to achieve your goal. First, start by creating this Sub in VBA (Press Alt+F11, right click "ThisWorkbook", Insert > Module, then copy and paste the following):

Sub SameColor()

Function ColorSum(CellColor As Range)
ColorSum = CellColor.Interior.ColorIndex

End Function

Next, create a new column in column C named ColorSum. In cell C2 put the formula =ColorSum(A2) and copy this formula down to C6. You should get values of 23, 40, 40, 50, 50 in cells C2:C6, respectively.

Finally, in cells B8:B10 put the following formulas:

Cell B8: =SUMIF(\$C\$2:\$C\$6,ColorSum(\$A\$5),\$B\$2:\$B\$6)

Cell B9: =SUMIF(\$C\$2:\$C\$6,ColorSum(\$A\$3),\$B\$2:\$B\$6)

Cell B10: =SUMIF(\$C\$2:\$C\$6,ColorSum(\$A\$2),\$B\$2:\$B\$6)

Now, I must warn you that this solution is set up specifically to solve the problem the way you have it designed. If you change the colors of cells A2:A6, or add more cells to the list, this solution may not work for you (i.e. it is not dynamic).

Hope this helps!
PReagan

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
48 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies