![](/img/trans.png)
[英]Trying to find the value of a cell in column b of the last row in sheet1
[英]Excel Macro Find Last Row In Column B, Select another cell A1, drag formula from A1 to last row in B
我正在尝试在Excel中进行自动填充,然后在其中创建宏:
B40
),并记住。 A1
。 A1
的公式A40
步骤1中找到的行(应为A40
)中,以执行自动填充公式。 我对VBA不太满意,因此非常感谢您的帮助。
这应该做您需要的。
' Get last row with data in column B...
Dim intLastRow As Long
intLastRow = Cells(Rows.Count, "B").End(xlUp).Row
' Fill column A down to this row...
Range("A1:A" & intLastRow).FillDown
在这种情况下,您甚至不需要Range.FillDown或Range.AutoFill方法。
With ActiveSheet
.Cells(1, 1).Resize(.Cells(Rows.Count, 2).End(xlUp).Row, 1) = .Cells(1, 1).Formula
End With
只需从左上角的单元格开始,然后使用Range.Resize属性将其扩展到所需的尺寸并传输公式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.