我有以下 Excel VBA 代码块。
现在我必须把它们放在一个循环中并参数化它们。
Countruz2 = 2
Countruz3 = Countruz2 + 13
Range("A2:A15").PasteSpecial (xlPasteValues)
以下是我尝试过的 - 3 个变体都失败了:无效使用属性错误。
' Range ("A" & Countruz2 & ":" & "A" & Countruz3) ' Invalid Use of Property
' Range ("A" & Countruz2 & ":A" & Countruz3) ' Invalid Use of Property
' Range ("A" & Countruz2 & ":A" & Countruz2 + 13) ' Invalid Use of Property
我们如何处理 Excel VBA 中 Range 函数中的此类连接和参数化?
感谢您提前提供的所有帮助。
编辑 :
像这样连接它后让它工作 -
X = "A"& Countruz2 & ":"& "A"& (Countruz2 + 13)
调试.打印 X
Range(X).PasteSpecial (xlPasteValues)
还有其他优雅/更简单的方式吗?
最佳答案
尝试这个
Countruz2 = 2
Countruz3 = Countruz2 + 13
Range("A" & Countruz2 & ":A" & Countruz3).PasteSpecial (xlPasteValues)
关于vba - Excel VBA范围变量连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51271859/