title: Copying a formula down through x number of rows
body: <p>I'm at a loss on this and need some help.  I've lurked around at answers and have Frankensteined together some code for a macro but it just isn't working.</p>
  
  <p>Here is part of what I have so far:</p>
  
  <pre><code>With ActiveSheet
  Firstrow = 1
  Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
  For lrow = Lastrow To Firstrow Step -1
  With .Cells(lrow, "G")
      Range("G1").Select
      ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[1]),RC[1],RC[-1])"
  End With
  Next lrow
  End With
  </code></pre>
  
  <p>I have a very similar block of code before this that deletes crap from the text files I'm importing and it works perfectly through all the number of rows.  When I run the same thing with this formula, it only puts the formula in G1 and doesn't cycle through the rest of the sheet.  I've tried this and it works, but copies down through all million plus rows:</p>
  
  <pre><code>ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[1]),RC[1],RC[-1])"
  Selection.AutoFill Destination:=Range("G:G")
  </code></pre>
  
  <p>I've tried this and then run the same code that gets rid of the text file crap but I get an error "End If without block If".</p>