我正在运行一个复制粘贴宏,但是当我运行它时,它会不断将我的公式范围更改为行的最后一行。
例如,我原来的 VLOOKUP 公式看起来从$D$2:$G$5000
,但是当我运行我的宏时,它会将其更改为$D$2:$G$1254
1254 是数据所在的最后一行。
这是复制+粘贴功能:
Sub START1()
Dim shCurrentWeek As Worksheet
Dim shPriorWeek As Worksheet
Dim lr As Long
Set shCurrentWeek = ActiveWorkbook.Sheets("Current Week")
Set shPriorWeek = ActiveWorkbook.Sheets("Prior Week")
lr = shCurrentWeek.Range("A" & Rows.Count).End(xlUp).Row
'Copies Current Week into Prior Week and deletes Rows in Prior week
shCurrentWeek.Range("A4:X" & lr).Copy
shPriorWeek.Range("A2").PasteSpecial xlPasteValues
shPriorWeek.Range("A" & lr - 2 & ":A10000").EntireRow.Delete
End Sub
有任何想法吗?