问题
I'm getting a "Compile error: Expected Function or variable" from this code
Cells(3, 2).Select
ActiveCell.FormulaR1C1 = Formula 'Inserts formula
'Copies formula across the row
Cells(3, 2).Copy
Range(Cells(3, 2), Cells(3, 10)).PasteSpecial xlPasteFormulas
Range(Cells(3, 2), Cells(3, 10)).Select
'Copies the formula down to end of list
selection.Copy '<---- Here it says it can't compile
Range(selection, selection.End(xlDown)).FillDown
Using "selection" here gives the error, yet works in another workbook. I'm trying to insert a formula into a cell, copy it across a range, and fill down to the end of the block of data. How do I either get it to work again? Or, is there another way to populate a range of cells with a formula (which changes often hence putting it in a variable.)
Thank you for your help,
Samuel Smith
来源:https://stackoverflow.com/questions/13635768/excel-vba-selection-copy-no-longer-works