View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default ColorIndex count function

On Wednesday, August 24, 2016 at 3:30:40 AM UTC-7, Claus Busch wrote:
Hi Howard,

Am Wed, 24 Aug 2016 03:21:40 -0700 (PDT) schrieb L. Howard:

I do have a problem with the function call formulas in a row (row 18 & pulled across many columns) =ColCnt(C4:C17) because adding a color to a cell does not fire the function formula.


try it this way:

Function ColCnt(myRng As Range, Optional FC As Boolean) As Long
Dim rngC As Range

Application.Volatile
For Each rngC In myRng
Select Case FC
Case False
If rngC.Interior.ColorIndex < xlNone Then
ColCnt = ColCnt + 1
End If
Case True
If rngC.Font.ColorIndex < xlAutomatic Then
ColCnt = ColCnt + 1
End If
End Select
Next
End Function

If you change the color you can press F9 to calculate new.



Hi Claus,

Yep! That is a winner. Thank you very much.

Howard