2010-06-03 40 views

回答

0

看起来有些方法可以使用Excel VBA执行此操作,但本机不能使用COUNTIF函数。 COUNTIF函数使用单元格中的数据作为条件 - 是否有一个数据条件用于确定也可用于COUNTIF函数的背景颜色?

0

你必须使用VBA(打开VBA编辑器ALT + F11)

  1. 首先由乳宁本次获得的颜色索引:

    Sub showColorIndices() 
    For i = 1 To 56 
        Range("A" & i).Interior.ColorIndex = i 
        Range("B" & i).Value = " " & i 
    Next 
    End Sub 
    

你会得到像这样:
color indices

  1. 然后你可以指望一个给定的显色指数具有这种功能的细胞数量:

    Function fnNbCellsColor(Plage As Range, ColorIndex As Integer) As Long 
    
    Dim rCell As Range 
    
    For Each rCell In Plage 
        If rCell.Interior.ColorIndex = ColorIndex Then 
         fnNbCellsColor = fnNbCellsColor + 1 
        End If 
    Next 
    
    End Function 
    

要计算蓝色细胞的数量,只写这个公式在您的工作表:

= fnNbCellsColor(D1:D20; 5) 
相关问题