我对VBA for Excel非常陌生,并且羞于承认我到目前为止还不明白我读过的内容! 我正在尝试从一张纸复制并粘贴到另一张纸上,然后将第二张纸的结果重新复制回第一张纸。我有大约5300件我希望复制的东西 - 从原始工作表中粘贴。这是录制的宏:
Sub Retreive_Code()
Range("L11").Select
Selection.Copy
Windows( _
"Unique License plate Valuation Algorithm.18March2014.V7.0.Winner!.xlsx"). _
Activate
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("L2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Complete Unique number sales.2010 - 2012.xlsx").Activate
Range("M11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
如果您有任何疑问,请与我们联系。 非常感谢
答案 0 :(得分:2)
请避免使用.Select/.Activate
INTERESTING READ
这是你在尝试的吗?
<强> UNTESTED 强>
Sub Retreive_Code()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
'~~> Set your workbooks here
Set wb1 = Workbooks("Unique License plate Valuation Algorithm.18March2014.V7.0.Winner!.xlsx")
Set wb2 = Workbooks("Complete Unique number sales.2010 - 2012.xlsx")
'~~> Change these to the respective sheets
Set ws1 = wb1.Sheets("Sheet1")
Set ws2 = wb2.Sheets("Sheet1")
'~~> Do the copy pasting
With ws2
ws1.Range("D12:D5283").Value = .Range("L12:L5283").Value
DoEvents
.Range("M12:M5283").Value = ws1.Range("L12:L5283").Value
End With
End Sub