我的代码在 excel 2007 中运行得非常好,但在 excel 2003 中没有运行。它给出“编译错误”并且这条线变成红色。
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
你的建议会有很大帮助。谢谢。如果您需要我这边的任何信息,请告诉我。
这是我的完整代码:
'-------------------------------------
' Create Final Report
'-------------------------------------
Sub FinalReport()
Dim thisWb As Workbook
Set thisWb = ActiveWorkbook
Dim btn, rght As Long
Dim NewWbk As String
NewWbk = "Final_Report"
' Add a new workbook
Application.Workbooks.Add
Range("A1").Select
' Rename the workbook
ActiveWorkbook.SaveAs Filename:=thisWb.Path & Application.PathSeparator & "Final_Report" & ".xls"
Windows("Tool_01082013.xls").Activate
Sheets("Reports").Activate
' select the sheet and range to be copied
Range("B2:AO34").Select
' Copy the selected range...
Selection.Copy
Workbooks("Final_Report.xls").Sheets("Sheet1").Activate
' and Paste it into the new workbook
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Windows("Tool_01082013.xls").Activate
Sheets("Reports_Month").Activate
' select the sheet and range to be copied
Range("A1:DR34").Select
' Copy the selected range...
Selection.Copy
Workbooks("Final_Report.xls").Sheets("Sheet2").Activate
' and Paste it into the new workbook
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Workbooks("Final_Report.xls").Save
Workbooks("Final_Report.xls").Close
Windows("Tool_01082013.xls").Activate
With Sheets("Reports")
.Activate
.Range("A5").Select '-- move focus to the first item
End With
End Sub