title: Putting complex formula to a cell
body: <p>I want to put a formula to a cell and the values that I will be using is based on another cell(not a fix cell). 
  This is the formula if it is on the excel's formula bar. </p>
  
  <pre><code>=IF(AND(D9=0,J9&lt;&gt;0),100%,IFERROR(K9/D9,0))
  </code></pre>
  
  <p>But I cannot  use this in vba because the formula should be flexible in every cell that I will be using this. Here's my code(I know its not good.)</p>
  
  <pre><code>ws.Range("L" &amp; src1).Formula = "=IF(AND(" &amp; ws.Range("D" &amp; src1).Value &amp; "=0," &amp; ws.Range("J" &amp; src1).Value &amp; "&lt;&gt;0),100%,IFERROR(" &amp; ws.Range("K" &amp; src1).Value / ws.Range("D" &amp; src1).Value &amp; ",0))"
  </code></pre>