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