我一直在尝试编写一个代码,用于计算一列中的彩色单元格和一些来自其他列的字符串(一个标准为单元格颜色的countifs)。我的代码返回#value。请帮忙。
Function ColorFunction(rColor As Range, rRange As Range, rref As Range, rRange2 As Range)
Dim rCell, rcell_ref As Range
Dim lCol As Long
Dim vResult
Dim i As Integer
lCol = rColor.Interior.ColorIndex
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
i = recell.Row
For Each rcell_ref In rRange2
If ((rcell_ref = rref.Value) And (rcell_ref.Row = i)) Then
vResult = 1 + vResult
End If
Next rcell_ref
End If
Next rCell
ColorFunction = vResult
End Function