简体   繁体   English

不断收到应用程序定义或对象定义的错误,而我看不到我做错了什么

[英]Keep getting application-defined or object-defined error, while i can't see what i did wrong

In my excel VBA code i wan't to copy from the sheet Calculatie to the sheet Gantt Chart, but when i wan't to paste to the cells in the Gantt Chart sheet i get an error. 在我的excel VBA代码中,我不想从工作表Calculatie复制到工作表甘特图,但是当我不想粘贴到工作表中的单元格时,会出现错误。 See code below. 请参见下面的代码。

Note that i used the "test" variable to see if i could get it working in an other way. 请注意,我使用“ test”变量来查看是否可以使它以其他方式工作。

Sub setValue()
Dim test As String

gantCell = Sheets("Gantt Chart").Rows("5:1000").SpecialCells(xlCellTypeVisible).Row
calcCell = gantCell - 3
formCell = gantCell + 1
Worksheets("Gantt Chart").Cells(gantCell, 6).Value = "1"
gantCellNext = Sheets("Gantt Chart").Rows("5:1000").SpecialCells(xlCellTypeVisible).Row
'code zoeken om alle cellen onder de 1e zichtbare cell de volgende formule te geven =rij 1 hoger dan de huidige cel + 1 rij en 1 kollum hoger
i = gantCell
test = "F" & i
MsgBox test
Sheets("Calculatie").Cells(calcCell, 2).Copy
Sheets("Gantt Chart").Range("test: F35").PasteSpecial Paste:=xlPasteValues, Operation:=xlPasteSpecialOperationMultiply
MsgBox formCell
MsgBox gantCell
MsgBox calcCell

End Sub

As follow up from comments, this one works: 作为评论的后续内容,这一行有效:

Sheets("Gantt Chart").Range(test).PasteSpecial Paste:=xlPasteValues, Operation:=xlPasteSpecialOperationMultiply

or 要么

Sheets("Gantt Chart").Range(test & ":F35").PasteSpecial Paste:=xlPasteValues, Operation:=xlPasteSpecialOperationMultiply

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试复制和粘贴时,我不断收到1004错误应用程序定义的错误或对象定义的错误 - I keep getting a 1004 Error Application-Defined or Object-Defined Error when trying to copy and paste 为什么使用简单的 VBA 宏会不断收到应用程序定义或对象定义的错误? - Why do I keep getting application-defined or object-defined error with simple VBA macro? 如何使用宏解决错误1004“应用程序定义的错误或对象定义的错误”? - How can I resolve error 1004 “Application-defined or object-defined error” with my macro? 获取有关应用程序定义或对象定义的错误的错误 - getting error about application-defined or object-defined error 在保护工作表时出现应用程序定义或对象定义的错误 - Getting Application-defined or object-defined error on protecting the sheet 获取应用程序定义或对象定义的错误 - Getting Application-defined or object-defined error 应用程序定义或对象定义的错误 - Application-defined or object-defined error 错误 1004“应用程序定义或对象定义的错误 - Error 1004 "Application-defined or Object-defined error Excel 宏中的错误:应用程序定义或对象定义错误 - Error in Excel macro: Application-defined or object-defined error “ <Application-defined or object-defined error> 错误1004” - “<Application-defined or object-defined error> Error 1004”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM