title: Using string variables within a formula in VBA
body: <p>I do not understand why this code doesn't work:</p>
  
  <pre><code>Cells(i, formula_col_index).Value = "=IF(" &amp; time_location &amp; "&lt;&gt;" &amp; time_benchmark &amp; ",""ERROR"",""OK"")"
  </code></pre>
  
  <p>where </p>
  
  <pre><code>time_location=" 17:00:00",
  time_benchmark=" 17:30:00"
  </code></pre>
  
  <p>It keeps throwing application-defined (or object-defined) error.</p>
  
  <p>Thanks in advance.</p>