ColorIndex count function
Hi Howard,
Am Wed, 24 Aug 2016 01:06:55 -0700 (PDT) schrieb L. Howard:
I thought I could alter any number of function examples that count the cells in a range for either the Font color or the Cell.Interior.ColorIndex or both.
I want to count ANY ColorIndex in a range like C4:C14. Where the call for the function would be something like =ColorCnt(C4:C14).
So any cell in that range with any of the 56 color index numbers colors would get counted.
try:
Function ColCnt(myRng As Range, Optional FC As Boolean) As Long
Dim rngC As Range
For Each rngC In myRng
Select Case FC
Case False
If rngC.Interior.ColorIndex < -4142 Then
ColCnt = ColCnt + 1
End If
Case True
If rngC.Font.ColorIndex < 1 Then
ColCnt = ColCnt + 1
End If
End Select
Next
End Function
You can call it in the sheet with
=ColCnt(C4:C14) for interior colorindex
or with
=ColCnt(C4:C14;1) for font colorindex
Regards
Claus B.
--
Windows10
Office 2016
|