title: Color cells based on cell value
body: <p>Can you help me what is wrong with my code. 
  I get an error: Application defined or object defined error.
  I would like to color a cell based on a cell value.
  If a cell value equal to a cell-1 value the cell should be red.
  Error with this line: If Cells(i, 2).Value = Cells(i - 1, 3).Value Then</p>
  
  <p>thank you</p>
  
  <pre><code>Sub colorcells()
  ThisWorkbook.Worksheets("Sheet1").Activate
  Range("A1").Select
      Dim i As Long
      lastrow = Cells(Rows.Count, "B").End(xlUp).Row
      For i = 1 To lastrow
          If Cells(i, 2).Value = Cells(i - 1, 3).Value Then
              Cells(i, 1).Interior.ColorIndex = 3
          End If
      Next i
  End Sub 
  </code></pre>