The macro below creates the formulas in the rows available and then fills the cell below with the same formulas to the exact range of cells specified when recording. However I have other applications or worksheets where the number of rows could be variables. How do I make run on variable ranges?
Sub FormulasInCells()
Range("I2").Select
ActiveCell.FormulaR1C1 = "=+R[-1]C+RC[-6]"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-7]>=0,RC[-7],0)"
Range("K2").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-8]<0,RC[-8],0)"
Range("I2").Select
Range("I2:K2").Select
Selection.AutoFill Destination:=Range("I2:K53")
Range("I2:K53").Select
End Sub
I would appreciate anybody's insight. Thanks.
Sub FormulasInCells()
Range("I2").Select
ActiveCell.FormulaR1C1 = "=+R[-1]C+RC[-6]"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-7]>=0,RC[-7],0)"
Range("K2").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-8]<0,RC[-8],0)"
Range("I2").Select
Range("I2:K2").Select
Selection.AutoFill Destination:=Range("I2:K53")
Range("I2:K53").Select
End Sub
I would appreciate anybody's insight. Thanks.