Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 遇到错误-1004';应用程序定义或对象定义错误';使用粘贴值_Vba_Excel - Fatal编程技术网

Vba 遇到错误-1004';应用程序定义或对象定义错误';使用粘贴值

Vba 遇到错误-1004';应用程序定义或对象定义错误';使用粘贴值,vba,excel,Vba,Excel,尝试将单元格值复制并粘贴到自身上时遇到错误1004(以消除公式并仅获取值)。当我把它记录在工作表上时,它工作得很好,但是当我在我的子程序中实现它时,它就不工作了。PasteSpecial行出现错误: If i = ws_count Then 'ws_count - 2 allows us to place the new tab before the last sheet in the data file (admin) Sheets(twomonthsago).Copy Bef

尝试将单元格值复制并粘贴到自身上时遇到错误1004(以消除公式并仅获取值)。当我把它记录在工作表上时,它工作得很好,但是当我在我的子程序中实现它时,它就不工作了。
PasteSpecial
行出现错误:

If i = ws_count Then
    'ws_count - 2 allows us to place the new tab before the last sheet in the data file (admin)
    Sheets(twomonthsago).Copy Before:=Sheets(ws_count - 2)
    Sheets(twomonthsago & " (2)").Name = lastmonth & " test"
    Sheets(twomonthsago).Cells.Copy
    Sheets(twomonthsago).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
我还尝试在粘贴之前直接选择
Range(“A1”)
,但仍然会出现错误。我所有的变量都分配了有效的字符串,所以这不是问题所在。

直接分配它

替换这些:

Sheets(twomonthsago).Cells.Copy
Sheets(twomonthsago).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
与:

直接分配

替换这些:

Sheets(twomonthsago).Cells.Copy
Sheets(twomonthsago).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
与:


你可以做
Sheets(两个月前)。Cells.PasteSpecial…
Too你可以做
Sheets(两个月前)。Cells.PasteSpecial…
tooUh哦,尝试后出现了“内存不足”错误。瞧,这就解决了它!非常感谢。祝贺你打破了50k的btw。哦,在尝试了这个之后,出现了一个“内存不足”的错误。瞧,这解决了它!非常感谢。祝贺你打破了50k btw。