Hey all,

I'll try to make this brief. Been working on it for a while and just can't get it figured out.

I have two separate sheets, one with data (C-Ports) and one with the result (C-Total). On my data page, if the text or cell (whichever is easier) is red, I do not want my SUMIF function on the results page to reflect that data. Here is my SUMIF function:
=SUMIF('C-Ports'!A$2:A$19995,A3,'C-Ports'!J$2:J$19995)

I have a VB script that will exclude specific colors, but I can't get it to work. Keep in mind, the data from "C-Ports" page is constantly changing. That specific data is populated by multiple other sheets. Here is my VB script.
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
How can I make this work? I want to add up everyone from my "C-Ports" page except specific rows that are in red. Those rows will change over time.