jrobin5881
Technical User
I'm trying to enter a formula in a cell using VBA. I've found code out there and have tried modifying it with no luck.
I have the active cell as N2 and in the cell I want a very simple formula =A2 which will display the value of A2 in cell N2. I want to increment the value of the formula by two as I move down the N column so in N3 I would have = A4, N4 would have = A6 etc.
I've tried modifying ActiveCell.FormulaR1C1 = "=Average(RC[-1],RC[-2])" to read ActiveCell.FormulaR1C1 = "=A2" but am ending up with '=A2' in the cell. I plan on adding a counter to increment the row reference by two as it loops through. Below is the code without the incrementer built in yet
Do
ActiveCell.FormulaR1C1 = "=A2"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
I have the active cell as N2 and in the cell I want a very simple formula =A2 which will display the value of A2 in cell N2. I want to increment the value of the formula by two as I move down the N column so in N3 I would have = A4, N4 would have = A6 etc.
I've tried modifying ActiveCell.FormulaR1C1 = "=Average(RC[-1],RC[-2])" to read ActiveCell.FormulaR1C1 = "=A2" but am ending up with '=A2' in the cell. I plan on adding a counter to increment the row reference by two as it loops through. Below is the code without the incrementer built in yet
Do
ActiveCell.FormulaR1C1 = "=A2"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))