title: IF conditional formula in VBA - Run-time error '1004'
body: <p>I am getting a Run-time error '1004' at the line with IF statement. Checked the previous posts, but could not find a relevant solution.
  My code is</p>
  <pre><code>Sub RefreshFormulae()
  Set sh = ActiveSheet
  lastR = sh.Range(&quot;B&quot; &amp; sh.Rows.Count).End(xlUp).Row
  sh.Range(&quot;$J$3:$K$&quot; &amp; lastR).ClearContents
  sh.Range(&quot;$H$3:$H$&quot; &amp; lastR).Formula = &quot;=$G3&quot;
  sh.Range(&quot;$K$3:$K$&quot; &amp; lastR).Formula = &quot;=IF($I3&lt;&gt;&quot;&quot;Not Found&quot;&quot;;$I3;&quot;&quot;&quot;&quot;)&quot;
  End Sub
  </code></pre>
  <p>Error is in the line below. Am I missing anything here?</p>
  <p><code>sh.Range(&quot;$K$3:$K$&quot; &amp; lastR).Formula = &quot;=IF($I3&lt;&gt;&quot;&quot;Not Found&quot;&quot;;$I3;&quot;&quot;&quot;&quot;)&quot;</code></p>