title: VBA function to test if cell is conditionally formatted in Excel
body: <p>I have written the function below to test if a cell has conditional formatting activated based upon the cell fill.</p>
  
  <pre><code>Function cfTest(inputCell)
  
      If inputCell.DisplayFormat.Interior.Color &lt;&gt; 16777215 Then
          cfTest = True
      Else
         cfTest = False
      End If
  End Function
  </code></pre>
  
  <p>It does not work however. Saying that, this method does.</p>
  
  <pre><code>Sub myCFtest()
  Dim R As Integer
  R = 2
  Do
      If Range("I" &amp; R).DisplayFormat.Interior.Color &lt;&gt; 16777215 Then
          Range("K" &amp; R).Value = True
      Else
          Range("K" &amp; R).Value = False
      End If
  
      R = R + 1
  
  Loop Until R = 20
  End Sub
  </code></pre>
  
  <p>Can anyone explain to me why the function will not work? </p>
  
  <p>Cheers.</p>
  
  <p><strong>EDIT</strong>: Updated function but not working for conditional formatting</p>
  
  <pre><code>Function cfTest(inputCell)
      If inputCell.Interior.ColorIndex &lt;&gt; -4142 Then
          cfTest = True
      Else
         cfTest = False
      End If
  End Function
  </code></pre>