Guzzlr
Well-known Member
- Joined
- Apr 20, 2009
- Messages
- 982
- Office Version
- 2021
- Platform
- Windows
Code:
Function SumByColor(CellColor As Range, rRange As Range)Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function
Hello All,
I have the following code to sum cells with a color.
This is working good on my worksheet tab for column range of H8:H4000. with Cell H4 = SumByColor(H9,H8:H4000)
The problem is if the color changes, in any cell, then I must go back and "click" on the newly created color to "refresh" the formula
Is there a way, that every time the macro is run, the color sum in cell H4 will always sum, regardless of which color is used and which cell in H8:H4000 is colored?
Basically, it looks like all I need to have is a code which will refresh the formula in H4, before the macro is run?
Thanks for the help
excel 2010
Last edited: