我正在尝试复制范围B7:O34
中输入数据的最后一行,并将其粘贴到范围A7:O7
中。
当我运行此宏时,我希望它覆盖A7:O7
中的数据,而不是继续在连续行中列出数据。
这就是我的尝试:
Sub CopyLastRow()
Dim lRw As Long
With ActiveSheet
lRw = Cells.Find("", .Range("A" & Rows.Count), , , xlByRows, xlPrevious).Row
.Rows(lRw).Copy
End With
With Sheets("Sheet1")
lRw = Cells.Find("", .Range("A" & Rows.Count), , , xlByRows, xlPrevious).Row
.Rows(lRw + 1).PasteSpecial Paste:=xlPasteValues
End With
End Sub
答案 0 :(得分:1)
rainfall
答案 1 :(得分:0)
你去..
Sub Button1_Click()
Dim sh As Worksheet, ws As Worksheet
Dim Rws As Long, rng As Range, Prng As Range
Set sh = ActiveSheet
Set ws = Sheets("Sheet1")
Set Prng = ws.Range("B6")
With sh
Rws = .Range("B34").End(xlUp).Row
Set rng = .Range("B" & Rws & ":O" & Rws)
End With
rng.Copy Prng
End Sub