Aug 02 2019 12:51 PM
How do I add cells with the same background color?
Aug 02 2019 01:08 PM
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
Aug 02 2019 03:13 PM
Aug 03 2019 02:28 PM - edited Aug 03 2019 02:53 PM
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