title: Checking ColorIndex property of the range of Cells
body: <p>I have strange problem. Let's say I have range of cells A5-J5 and I tinker with their colors. I change ColorIndex property based on some conditions. If the whole range has the same color I want to trigger some actions. Easy enough. When I change color of all cells in range manually (to black which ColorIndex is 1) the below code returns "TRUE" and everything works fine.</p>
  
  <pre><code>Sub test()
      If Range(Cells(5, 1), Cells(5, 10)).Interior.ColorIndex = 1 Then
          MsgBox "TRUE"
      Else
          MsgBox "FALSE"
      End If
  End Sub
  </code></pre>
  
  <p>However I do not want to change cell fill manually of course. I am using VBA code that changes their ColorIndex when some conditions are met. After whole range is changed to ColorIndex=1 with VBA code, the below code returns FALSE.</p>
  
  <pre><code>Sub testt()
  
      If Range(Cells(5, 1), Cells(5, 10)).Interior.ColorIndex = 1 Then
          MsgBox "TRUE"
      Else
          MsgBox "FALSE"
      End If
  
      Dim i As Integer
      For i = 1 To 10
          MsgBox Cells(5, i).Interior.ColorIndex &amp; " Cell no " &amp; i
  
      Next i
  End Sub
  </code></pre>
  
  <p>To check if every cell in this range has the same ColorIndex I loop through them. Every cell has ColorIndex=1. However whole range does not it seems - because it returns FALSE. This occures only if I change color of cells with VBA, when I do it matually everything runs just fine.</p>
  
  <p>I know that I do not provide too many details, however perhaps someone here had simillar problem. Sorry if this question is too trivial but I really do not find any logical explanation to this.</p>