我希望根据有多少单元格颜色为绿色来填充一个单元格值。
示例1:
A1 B1 C1 D1 (E1- Answer '15%' will appear here)
G NG NG NG (G= Green, NG= Not Green)
另一个例子:
A1 B1 C1 D1 (E1- Answer '30%' will appear here)
G G NG NG (G= Green, NG= Not Green)
=IF(GetFillColor(A1)=4,"1",AND IF(GetFillColor(A1:B1)=4,"2"), AND IF(GetFillColor(A1:C1)=4,"3"), AND IF(GetFillColor(A1:C1)=4,"4", "0"))
GetFillColour:
Function GetFillColor(Rng As Range) As Long
GetFillColor = Rng.Interior.ColorIndex
End Function
非常感谢任何帮助,谢谢!
答案 0 :(得分:0)
尝试使用以下命令更改getfillcolor函数:
Public Function getfillcolor(rng As Range, color As Long) As Integer
Dim i As Integer
Dim cell As Range
For Each cell In rng.Cells
If cell.Interior.color = color Then
i = i + 1
Else
End If
Next cell
getfillcolor = i
End Function
现在,您可以直接在指定的单元格中使用您的总和。
答案 1 :(得分:0)
如果您不介意使用 helper 单元格(并且没有VBA):
=GET.CELL(38,OFFSET(INDIRECT("RC",FALSE),-1,0))
=CellColour
1个单元格放在有色单元格下方
公式中的偏移量告诉它查看上面的行。 =COUNTIF(A2:D2,10)/COUNTA(A2:D2)
您需要按F9更新公式结果。
http://www.mrexcel.com/forum/excel-questions/20611-info-only-get-cell-arguments.html