[英]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.