0
我在Excel中有一個宏,但是當我嘗試使用Selection.PasteSpecial
進行粘貼時,它向我顯示錯誤1004。vb excel error 1004 Selection.PasteSpecial
如果我嘗試使用Office 2010中的相同宏,則此錯誤與Office 365無關。
調試器示出了在這一行一個錯誤:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
模塊的完整代碼是:
Sub MoveData_Activations()
MoveData_Activations Macro
Dim dayCount As Integer
Dim startCell As String
Dim curCellRef As String
dayCount = 13
startCell = "B3"
If MsgBox("Are you sure you want to rollover the data for a new date?", vbYesNo, "Confirm rollover") = vbYes Then
ActiveSheet.Protect UserInterfaceOnly:=True
Range(startCell).Select
ActiveCell.Cells(-1, 6).Copy
ActiveCell.Cells(-1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
curCellRef = Range(startCell).Address
For i = 1 To dayCount
CopyData curCellRef, False, 6, 24, 2
curCellRef = ActiveCell.Cells(1, 6).Address
Next i
CopyData curCellRef, True, 6, 24, 2
End If
End Sub
不知道,但閱讀[這](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros)。 – Kyle