我有兴趣将大范围从一个工作簿复制到另一个工作簿。目前,我正在使用复制和粘贴功能。该宏处理较小的文件,但现在我有一个非常大的文件,我在if(isset($_POST["bt_signature"]) && isset($_POST["bt_payload"])) {
$webhookNotification = Braintree_WebhookNotification::parse(
$_POST["bt_signature"], $_POST["bt_payload"]
);
}
遇到错误。我认为这是因为我复制的内容对于剪贴板来说太大了。听起来不错吗?如果是这样,我想一起避免剪贴板。这是我目前的代码。
ActiveSheet.Paste
答案 0 :(得分:1)
使用以下其中一项:
Option Explicit
Public Sub valuesCopy()
With DeptReceivedWB.Sheets(1).Cells(1, 1).CurrentRegion
.Offset(1).Resize(.Rows.Count - 1, .Columns.Count).Copy
End With
APPS_AuditWB.Sheets(3).Cells(1, 1).PasteSpecial xlPasteValues
End Sub
Public Sub directCopy1()
Dim cr As Range, fr As Long, lr As Long, fc As Long, lc As Long
Set cr = DeptReceivedWB.Sheets(1).Cells(1, 1).CurrentRegion
fr = cr.Row: lr = fr + cr.Rows.Count - 2
fc = cr.Column: lc = fc + cr.Columns.Count - 1
Set cr = cr.Offset(1).Resize(lr, lc)
With APPS_AuditWB.Sheets(3)
.Range(.Cells(fr, fc), .Cells(lr, lc)).Value2 = cr.Value2
End With
End Sub
Public Sub directCopy2()
Dim cr As Range, fr As Long, lr As Long, fc As Long, lc As Long
Set cr = DeptReceivedWB.Sheets(1).Cells(1, 1).CurrentRegion
fr = cr.Row: lr = cr.Rows.Count - 1
fc = cr.Column: lc = cr.Columns.Count
Set cr = cr.Offset(1).Resize(lr, lc)
With APPS_AuditWB.Sheets(3)
.Cells(fr, fc).Resize(lr, lc).Value2 = cr.Value2
End With
End Sub
答案 1 :(得分:0)
我建议您只复制所需的范围,而不是复制(可能)标题行,然后将其从目标中删除:
Dim rgCopy as range
set rgCopy = DeptReceivedWB.Sheets(1).Cells(1, 1).CurrentRegion
set rgCopy = rgCopy.Resize(rgCopy.Rows.Count - 1).Offset(1)
rgCopy.Copy Destination:=APPS_AuditWB.Sheets(3).Cells(i + 1, 1)