[英]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.