title: Type mismatch error, why?
body: <p>Can anyone explain why there is type mismatch when <strong>If range...</strong> runs?<br>
  here is my code</p>
  
  <pre><code>Sub Button2_Click()
  Dim i As Integer
  Dim k As Integer
  For i = 2 To 1000
  For x = 3 To 999
  If Range("k" &amp; i &amp; ":bn" &amp; i).Value = Range("k" &amp; x &amp; ":bn" &amp; x).Value And Cells(i, 5).Value &lt;&gt; Cells(x, 5).Value Then
  Range("k" &amp; i &amp; ":bn" &amp; i).Interior.ColorIndex = 7
  Range("k" &amp; x &amp; ":bn" &amp; x).Interior.ColorIndex = 7
  End If
  Next x
  Next i
  
  End Sub
  </code></pre>
  
  <p>I tried to use <code>Cstr()</code> but nothing changed</p>
  
  <p>UP: I've tried to use one more loop and cells instead of range and only thing I get is application-defined or object-defined error for this:</p>
  
  <pre><code>Dim z As Integer
  ...
  For z = 6 To 30
  If Cells(i, z).Value = Cells(x, z).Value And Cells(i, 5).Value &lt;&gt; Cells(x, 5).Value Then
  </code></pre>
  
  <p>tnx in advance</p>