Excel 2010 VBA Autofill entire column

て烟熏妆下的殇ゞ 提交于 2019-12-24 08:47:33

问题


I am having trouble getting VBA to do the equivalent of Autofilling an entire row (such as when you double click on the plus sign of a cell with a formula and it autofills the appropriate number of columns).

Along Column A I have a list of dates. Along Row 3 I have a list of formulas. How do I write a macro which will effectively do this:

For i = 2 to Columns.Count
    'FillDown the whole of Column i with the formula in Cells(3,i)
Next i

I want the fill down, not just a copy of the exact formula... Does anyone know how this can be done? I've got a method which is taking about 20 minutes so far but when I do this process manually it takes not very much time at all, so I think there must be a much faster way.

Thanks very much in advance for your help!


回答1:


You can try to use Autofill with a destination range.

Something like:

Selection.AutoFill Destination:=Range("A2:A12")

[EDIT] Or:

Range("A1").AutoFill Destination:=Range(Cells(1, firstColNumber), Cells(1, lastColNumber))


来源:https://stackoverflow.com/questions/7889987/excel-2010-vba-autofill-entire-column

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