title: How to correctly compare two values?
body: <p>I have an Excel VBA procedure which is supposed to compare the values of two cells. In my case they are scalars, ranging from <code>1</code> to <code>3</code>. Basically, they are answers to questions. If they match, then I want to color a certain cell <code>green</code>, otherwise I want to make it <code>red</code>. Is there something wrong with my syntax?</p>
  
  <pre><code>Sub CheckBold()
  '
  ' CheckBold Macro
  '
  
  '
   Row = ActiveCell.Row
   If ThisWorkbook.Sheets(1).Range("D" &amp; CStr(ActiveCell.Row)).Font.Bold Then
   ActiveCell.Value = 1
   End If
   If ThisWorkbook.Sheets(1).Range("E" &amp; CStr(ActiveCell.Row)).Font.Bold Then
   ActiveCell.Value = 2
   End If
   If ThisWorkbook.Sheets(1).Range("F" &amp; CStr(ActiveCell.Row)).Font.Bold Then
   ActiveCell.Value = 3
   End If
  
    ActiveCell.Value = ThisWorkbook.Sheets(3).Range("A" &amp; CStr(ActiveCell.Row)).Value &amp; ActiveCell.Value
  
  If CInt(ActiveCell.Value) = CInt(ThisWorkbook.Sheets(3).Range("A" &amp; CStr(ActiveCell.Row)).Value) Then
      ActiveCell.Interior.Color = RGB(0, 180, 0)
  Else
      ActiveCell.Interior.Color = RGB(180, 0, 0)
  End If
  
  
  
  End Sub
  </code></pre>
  
  <p>What happens is that always the code goes on the <code>Then</code> branch of the if, even though the values are different. Why do I get this behavior?</p>