【发布时间】:2019-08-13 01:57:22
【问题描述】:
我的成功之处:
我能够将“Sheet1”上从 F2 开始的列粘贴到“加载文件”工作表上,因为我知道该列将从 E2 开始。
我正在努力解决的问题:
我需要复制同一列,将列中的每个值加 28(值是日期),然后将结果粘贴到我刚刚粘贴的列的正下方
这是我尝试过的代码。第一点就像我提到的那样工作
'Developement Complete
Set ws = Application.Worksheets("Sheet1")
endRowSheet1 = ws.UsedRange.Rows.Count
Set wsOut = Application.Worksheets("Load File")
Set r = ws.Range(Cells(2, 1), Cells(endRowSheet1, 1))
r.Copy
wsOut.Range("A2").PasteSpecial xlPasteAll
Set r = ws.Range(Cells(2, 6), Cells(endRowSheet1, 6))
r.Copy
wsOut.Range("E2").PasteSpecial xlPasteAll
endRowDevelopment = wsOut.UsedRange.Rows.Count
'Compliance Regulatory
'need to add 28 to the value in each cell of copied column
Set r = ws.Range(Cells(2, 1), Cells(endRow, 1))
r.Copy
wsOut.Range(Cells(endRowDevelopment + 1, 1), Cells(endRowDevelopment * 2 + 1, 1)).PasteSpecial xlPasteAll
Set r = ws.Range(Cells(2, 6), Cells(endRow, 6))
r.Copy
wsOut.Range(Cells(endRowDevelopment + 1, 5), Cells(endRowDevelopment * 2 + 1, 5)).PasteSpecial xlPasteAll
End Sub
我收到运行时错误 1004,所以我怀疑我使用 range 函数的方式有问题。
【问题讨论】: