我正在尝试填充从B列的最后一行到I到J列的最后一行的数据。我已经绑定了以下代码,但它不起作用。
Sub Macro3()
Dim lrow As Long
LW = Worksheets("master log-1").Cells(Rows.Count, 10).End(xlUp).Row
NW = Worksheets("master log-1").Cells(Rows.Count, 2).End(xlUp).Row
MsgBox "Last Row: " & LW
MsgBox "Last Row: " & NW
Worksheets("master log-1").Range("B" & NW, "I" & NW).AutoFill Destination:=Range("B:I" & lrow), Type:=xlFillCopy
End Sub发布于 2020-04-15 17:02:47
我认为这就是你一直在尝试做的事情。请试一试。
Sub AppendRows()
Const NumRows As Long = 3 ' enter how many rows to append
Dim Ws As Worksheet ' always declare the sheet you are working on
Dim Rng As Range
Set Ws = Worksheets("master log-1")
' make sure the row is the same for both ends of the range
Set Rng = Ws.Cells(Rows.Count, 2).End(xlUp).Resize(1, 8)
Rng.AutoFill Destination:=Rng.Resize(NumRows + 1, Rng.Columns.Count)
End Sub您的代码需要一个预先确定的最后一行。我认为这是一个导数,你真的想要添加一定数量的行。如果我弄错了,所需的代码更改将是微不足道的。
https://stackoverflow.com/questions/61224402
复制相似问题