As the question (and the file) is about UDF, it probably suits better to https://www.excelforum.com/excel-pro...ng-vba-macros/ subforum.
But anyway:
Accessing the formatting applied to a cell by conditional formatting is not an easy tesk. so probably it's better to directly count the situations, which are markled by conditional formatting. The simple UDF could be:
Function CountCurrentWeek(rStartAndEndColumns As Range, lCurrentWeek As Long) As Long
Dim arr As Variant, i As Long, lTmpResult As Long
arr = rStartAndEndColumns.Value
For i = 1 To UBound(arr)
If arr(i, 1) <= lCurrentWeek And arr(i, 2) >= lCurrentWeek Then lTmpResult = lTmpResult + 1
Next i
CountCurrentWeek = lTmpResult
End Function
The same could be obtained (and then posting in formulas subforum is just right) with regular formula:
Formula:
=COUNTIFS($J$13:$J$157,"<="&M11,$K$13:$K$157,">="&M11)
(this approach is presented in a copy of original sheet)
Bookmarks