问题
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
Does it mean that excel stores Range values by default in value2? I'm just curious how it works.
回答1:
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.
The optional argument is listed in MS Help as: .Value(RangeValueDataType)
where RangeValueDataType
takes one of the enumeration values:
xlRangeValueDefault
xlRangeValueMSPersistXML
xlRangeValueXMLSpreadsheet
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
.

来源:https://stackoverflow.com/questions/28643876/range-value-not-shown-in-locals-window-in-excel-vba