发布网友 发布时间:2022-04-23 04:56
共3个回答
热心网友 时间:2023-10-15 12:32
ALT+F11——菜单栏——插入——模块:
FunctionCountByColor(Ref_color As Range, CountRange As Range)
Application.Volatile
DimiCol As Integer
DimrCell As Range
iCol= Ref_color.Interior.ColorIndex
ForEach rCell In CountRange
IfiCol = rCell.Interior.ColorIndex Then
CountByColor= CountByColor + 1
EndIf
NextrCell
EndFunction
在C15输入
=CountByColor(B15,B2:B11)
在E15输入
=CountByColor(D15,C2:C11)
均回车。
热心网友 时间:2023-10-15 12:32
可以做一个自定义函数,来统计颜色的个数。追问我是个纯菜鸟,请问该怎么做自定义函数呢???
追答Option Explicit
Function yansecount(rngs As Range, rng As Range) As Integer
Dim rgs As Range
Dim n%
For Each rgs In rngs
If rgs.Interior.ColorIndex = rng.Interior.ColorIndex Then n = n + 1
Next
yansecount = n
End Function
热心网友 时间:2023-10-15 12:33
我也等,如果有知道的请@一下我