Excel VBA Selection.Copy no longer works

时光毁灭记忆、已成空白 提交于 2019-12-12 23:51:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!