I wrote UDF to count cells of a certain color and with some LineStyles, I send the whole function:
Function CountTime(rData As Range, cellRefColor As Range) As Variant
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Variant
Application.Volatile
cntRes = 0
indRefColor = cellRefColor.Cells(1, 1).Interior.Color
For Each cellCurrent In rData
If indRefColor = cellCurrent.Interior.Color Then
cntRes = cntRes + 1
End If
If cellCurrent.Borders(xlDiagonalUp).LineStyle <> xlNone Then
cntRes = cntRes + 0.5
End If
Next cellCurrent
CountTime = cntRes
End Function
Now the problem is that the formula does not calculate automatically when one of the cells in rDatahas color or linear properties. I added Application.Volatile, and I also tried calling the calculation using Worksheet_Change, but this does not work, since Excel does not seem to consider color changes in a cell / sheet.
Is there a way to make the cell automatically calculate and update when the user changes the color or properties of the cell line in rData?
-
ignotus, ChangeSelection . .
, .