Hi All,
I have the following subroutine from a recorded macro:
Sub GenerateCorrosionProfile()
Range("I14").Select
ActiveCell.FormulaR1C1 = "=RC[-6]" 'Writes =C14 to I14
Range("J14").Select
ActiveCell.FormulaR1C1 = "=R10C4" 'Writes =$D$10 to J14
Range("K14").Select
ActiveCell.FormulaR1C1 = "=RC[-8]" 'Writes =C14 to K14
Range("L14").Select
ActiveCell.FormulaR1C1 = "=RC[-5]" 'Writes =G14 to L14
Range("M14").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-5]" 'Writes =K14+H14 to M14
Range("N14").Select
ActiveCell.FormulaR1C1 = "=RC[-7]" 'Writes =G14 to N14
Range("O14").Select
ActiveCell.FormulaR1C1 = "=RC[-4]+RC[-7]" 'Writes =K14+H14 to O14
Range("P14").Select
ActiveCell.FormulaR1C1 = "=R10C4" 'Writes =$D$10 to P14
Range("I14:P14").Select
Selection.AutoFill Destination:=Range("I14:P65"), Type:=xlFillDefault
Range("I14:P65").Select
Range("I65").Select
End Sub
It's doing nothing more than copying data to cells in I14 to P14 and then pasting (autofill) all the data in I14:P14 to row 65 (see screen capture of the spreadsheet below to get a better understanding).
ScreenCap.JPG
I would like to remove the restriction of only pasting to the 65th row and have a loop that would allow the user to paste to as many rows as is required until there is no more data to perform an operation on. i.e. make the loop stop once a blank cell is reached in =RC[-6].
Side note: The macro is using the term =RC[-6] for =C14. What's going on there then?
Best Regards,
Aaron
Bookmarks