Hello everyone
I have UDF function that enables me to count colored cells (conditional formatting cells) and sum the values of colored cells
Function CountCFCells(Rng As Range, C As Range, bCount As Boolean)
Dim I As Single, J As Long
Dim Chk As Boolean, Str1 As String, CFCELL As Range
Application.Volatile
Chk = False
For I = 1 To Rng.FormatConditions.Count
If Rng.FormatConditions(I).Interior.ColorIndex = C.Interior.ColorIndex Then
Chk = True
Exit For
End If
Next I
J = 0
If Chk = True Then
For Each CFCELL In Rng
Str1 = CFCELL.FormatConditions(I).Formula1
Str1 = Application.ConvertFormula(Str1, xlA1, xlR1C1)
Str1 = "=" & CFCELL.Address & Split(Str1, "]")(UBound(Split(Str1, "]")))
If bCount = False Then
If Evaluate(Str1) = True Then J = J + 1
Else
If Evaluate(Str1) = True Then J = J + CFCELL
End If
Next CFCELL
Else
CountCFCells = "Color Not Found"
Exit Function
End If
CountCFCells = J
End Function
I need to update results of the UDF .. as I noticed the following ..if I select any cell withing A1:B15 which has conditional formatting rules, the results give a value error ..but when selecting any other cell , everything goes right..
Can I fix this debug?
Bookmarks