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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 12:38:44  来源:igfitidea点击:

VBA to fill formula down until last row in empty column

excelvbaexcel-vbaformula

提问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 C2Autofillthe column Cuntil 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