Excel VBA 的本地窗口中未显示范围值 [英] Range value not shown in locals window in Excel VBA
问题描述
我想知道为什么本地窗口中列出的范围对象没有值属性.value2 列在那里.同时我在代码中使用 Range.Value 并且它工作正常:
I was wondering why there is no value property for range object listed in locals window. The value2 is listed there. At the same time I use the Range.Value in the code and it works ok:
Set Rng = Range("D6:D9")
Set Rng2 = Range("B2:B5")
Rng2.Value = Rng.Value
这是否意味着excel默认将Range值存储在value2中?我只是好奇它是如何工作的.
Does it mean that excel stores Range values by default in value2? I'm just curious how it works.
推荐答案
我相信 .Value
属性没有在调试窗口中单独列出,因为自 Office 2007 版以来,添加了一个可选参数,并且根据通过类模块编写目标代码的经验,局部窗口中只列出没有参数的属性.显示的另一个非常有用的属性是: .Address
但这同样有多个可选参数,所以我相信正是出于这个原因,它没有列出..Value2
另一方面不接受任何参数,因此出现在本地窗口中.
I believe the .Value
property is not listed separately in the debug windows as since Office version 2007, an optional argument was added and from experience with writing object code via class modules, only properties without arguments are listed in the locals window. Another property that would be very useful to have shown would be: .Address
but again this has multiple optional arguments so i believe it's for this reason it's not listed. .Value2
on the other hand takes no arguments and so does appear in the locals window.
可选参数在 MS 帮助中列为: .Value(RangeValueDataType)
其中 RangeValueDataType
采用枚举值之一:
The optional argument is listed in MS Help as: .Value(RangeValueDataType)
where RangeValueDataType
takes one of the enumeration values:
xlRangeValueDefault
xlRangeValueMSPersistXML
xlRangeValueXMLSpreadsheet
但也许您错过了 .Value
是否以灰色显示在本地/监视"窗口的顶层(如图所示)?这是因为 .Value(xlRangeValueDefault)
是 Range
的默认值.
But perhaps you missed that .Value
does appear at the top level in the Local/Watch window in grey (as shown)? This is because .Value(xlRangeValueDefault)
is the default value of Range
.
这篇关于Excel VBA 的本地窗口中未显示范围值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!