指定された異なる色でセルの値をカウントするには、あなたの助けが必要です.
1 つのシートで、いくつかのセルが赤色で塗りつぶされ、いくつかのセルが青色で塗りつぶされ、いくつかのセルが緑色で塗りつぶされます。出力は、赤色の細胞数、青色の細胞数、緑色の細胞数を別々に表示する必要があります。
これは私が試したことです:
Function CountByColor(InputRange As Range, ColorRange As Range) As Long
Dim cl As Range
TempCount As Long
ColorIndex As Integer
ColorIndex = ColorRange.Cells(1, 1).Interior.ColorIndex TempCount = 0
For Each cl In InputRange.Cells
If cl.Interior.ColorIndex = ColorIndex
Then
TempCount = TempCount + 1
End If
Next cl
Set cl = Nothing CountByColor = TempCount
End Function