=SumByColor is not working.
Hello All,
This is my first time posting so go easy on me. Im working on my finances and I wrote an AVB macro that will Add the numbers of a cell with the same color background. The Macro works on some cells but not on others and I have no idea what i'm doing wrong. I can provide screen shots. This is the code I used for the macro:
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
It just stoped working and will only show this: =SumByColor(D146, D101:D160) instead of the actual answer.