用自定函数ZHYZ(单元格区域,样本颜色所在的单元格)
Function ZHYZ(rag1 As Range, rag2 As Range)
Application.Volatile
For Each i In rag2
If i.Interior.ColorIndex = rag1.Interior.ColorIndex Then
ZHYZ = ZHYZ + 1
End If
Next
End Function
参考资料:http://club.excelhome.net/thread-504871-1-1.html