title: VBA Fill cells on multiple sheets with formulas
body: <p>I'm trying to set formulas for each cells in every sheet of a workbook. There are 2 formulas that I need to distribute across 2 different ranges of cells. I defined strFormula 1 and 2 in a Variant. </p>
  
  <p>For formula 1 I hope to distribute to cells under column A to AJ</p>
  
  <p>For formula 2 I hope to distribute to cells under column AK to AR</p>
  
  <p>I received following error after running the loop and a syntax error when defining strFormulas(2). Would like some help on fixing those problems.</p>
  
  <p>Thank you!</p>
  
  <blockquote>
    <p>Run time error 1004, Application-defined or object-defined error</p>
  </blockquote>
  
  <pre><code> Dim w As Long
   Dim strFormulas(1 To 2) As Variant
  
   For w = 2 To ActiveWorkbook.Worksheets.Count
      With ActiveWorkbook.Worksheets(w)
  
          strFormulas(1) = "=IF(ISBLANK('Sheet 1'!A4),"",'Sheet 1'!A4)"
          'strFormulas(2) has a syntax error.
          strFormulas(2) = "=IF('Sheet 2'!N1838="S","S","")"
  
          .Range("A2:AJ2").Formula = strFormulas(1)
          .Range("A2:AJ2000").FillDown
          .Range("AK2:AR2").Formula = strFormulas(2)
          .Range("AK2:AR2000").FillDown
  
      End With
  Next w
  </code></pre>