PDA

View Full Version : copy down formula



satyen
03-31-2010, 12:29 AM
Good morning!

I am using this piece of code to copy a formula down. I am using column A as base for how many rows to copy down to. Adjacent column is not always populated fully.

It copies down ok however copies down one extra row.
I deleted this row to make sure its not reading a space or anything, but still happening. Is there more of an efficient way of writing this?

LRw = Cells(Rows.Count, "A").End(xlUp).Row - 1
ActiveCell.Resize(LRw - 1).FormulaR1C1 = "=IF(RC[-2]=0,""-"",(RC[-1]/RC[-2]))"

Can anyone have a quick look. Much appreciated.

Bob Phillips
03-31-2010, 12:53 AM
Maybe this?



With ActiveCell

LRw = Cells(Rows.Count, "A").End(xlUp).Row - .Row + 1
.Resize(LRw).FormulaR1C1 = "=IF(RC[-2]=0,""-"",(RC[-1]/RC[-2]))"
End With