我正在尝试将手动复制的工作表粘贴到名为“数字 - 输入”的工作表中。
我有时会收到错误
Range 类的 Pastespecial 方法失败
这是我的粘贴声明:
Worksheets("Digital - Input").range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
这是我的完整代码:
Sub pasteDigitalInput()
Application.ScreenUpdating = False
'open the source sheet
Call unlockAll
'show the input sheet
Call showerfunc("Digital - Input")
'paste values
'On Error GoTo feilmeld
Worksheets("Digital - Input").range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Update cell references
Call getTotals
'Set the start of ukestrykk for digital
showerfunc ("Kilder")
Sheets("Kilder").Select
range("J2").Select
Call findAnd("Netto spend pr uke:", "Kilder", "Digital - Input", 2, 0, , , True)
hiderfunc ("Kilder")
'Hide sheet
Call hiderfunc("Digital - Input")
Sheets("Digital").Select
Application.ScreenUpdating = True
'locks the sheet again
Call lockAll
Exit Sub
feilmeld:
'hiderfunc ("Digital - Input")
Sheets("Digital").Select
Call lockAll
Application.ScreenUpdating = True
MsgBox ("Du må kopiere planen fra excel utskriften til Adform før du bruker denne knappen. OBS! kopier planen på nytt og lås opp Digital arket før du prøver igjen.")
End Sub
编辑: 打开两个工作簿后似乎可以正常工作。但是,如果我使用任何其他宏,尤其是清理输入表的宏,我会收到错误消息。
清理输入表宏:
Sub clearInputDigital()
Call ClearInput("Digital - Input", "Digital")
End Sub
Sub ClearInput(inputsheet As String, sourceSheet As String)
Application.ScreenUpdating = False
'Show the sheet
showerfunc (inputsheet)
Sheets(inputsheet).Select
Cells.Select
Selection.ClearContents
'Hide the sheet
hiderfunc (inputsheet)
Sheets(sourceSheet).Select
Application.ScreenUpdating = True
End Sub