Hey there,
I'm using this Colorfunction VBA from ozgrid
However, I want to sum cells that not only have a certain background color, but also have a certain value in an adjacent cell. Is there a way to do this by editing the VBA? Or another method?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
Have attached a sample, where in cell C11, I want to sum cells that are blue AND rank = 1 in column A.
Have entered expected results in red text.
Thanks for the help in advance!
Leaflock_sample.xlsm
Bookmarks