Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,806
- Office Version
- 2016
- Platform
- Windows
Hi,
I came accross this topic Excel VBA User Defined Function that counts cells with conditional formatting
for counting cells with CF and there was an answer offering a neat workaround which uses the handy Evaluate function to make the DisplayFormat work inside a UDF.
Here is an adaption:
Usage:
I hope you find this useful.
I came accross this topic Excel VBA User Defined Function that counts cells with conditional formatting
for counting cells with CF and there was an answer offering a neat workaround which uses the handy Evaluate function to make the DisplayFormat work inside a UDF.
Here is an adaption:
VBA Code:
Option Explicit
Function DFColor(ByVal R As Range) As Double
Application.Volatile
DFColor = Evaluate("Helper(" & R.Address() & ")")
End Function
Private Function Helper(ByVal R As Range) As Double
Helper = R.DisplayFormat.Interior.Color
End Function
Usage:
VBA Code:
=DFColor(A1)
I hope you find this useful.