vba VBA向下填充公式直到空列中的最后一行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44191297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA to fill formula down until last row in empty column
提问by Daniel
I have a report with a row count that changes daily. I need to autofill column C with a formula down to the last row of column B (columns A and B have different row counts, if that matters).
我有一个报告,其中的行数每天都在变化。我需要用公式自动填充 C 列到 B 列的最后一行(A 列和 B 列有不同的行数,如果这很重要)。
I have the formula in C2 (and a header in C1), how do I get vba to copy the formula in C2 down to the same row number as column B?
我有 C2 中的公式(以及 C1 中的标题),如何让 vba 将 C2 中的公式复制到与 B 列相同的行号?
回答by A.S.H
let C2
Autofillthe column C
until the last populated cell in column B
:
让C2
自动填充列C
直到列中的最后一个填充单元格B
:
With Sheets("Report")
.Range("C2").AutoFill .Range("C2:C" & .Cells(.Rows.count, "B").End(xlUp).row)
End With