View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default When do you need .Value?

Had a hard time finding this...

Default Property/Methods for Objects in Visual Basic
http://support.microsoft.com/default...57&Product=xlw

To add to Tushar's warning, one needs to be aware of the potential problems
with the value property when referring to dates and currency. Value2 may be
more appropriate.

I noticed the following bug is still present in Excel 2003.
If one has a vba code similar to the following
v = Range("A1").Value
and you do an "Add Watch" to the statement "Range("A1")"

then the "Value" property is still missing from this list. Using "Add
Watch" is a nice way to determine what properties are available for an
object. So, it's a little troublesome to see "Value" missing.

(looks like "Address" is still missing also, and perhaps a few others)
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dana DeLouis" wrote in message
...
Value is the default property of the Range object.


Just for discussion, here is a copy from vba's help on "Cells Property"

<..copy
Remarks:
Because the Item property is the default property for the Range object,

....
<..end copy

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dick Kusleika" wrote in message
...
All,

Value is the default property of the Range object. Item is the default
property of the Cells property which returns a Range object. That's why
Range("A1") = Range("a1").Value is True and Cells(1,2) = Cells.Item(1,2)

is
True. There is no cell object.

I'm curious why omitting the Value property would be more efficient. I
would think the opposite. If I don't include it, the VBA has to figure

out
what type of object I'm using, look up its default property and process

from
there. If I don't omit it, there's no lookup. I don't have any real
evidence of this, it's just what I think would happen.

FWIW, I also include every default property. But I'm willing to learn.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com



Alan Beban wrote:
I'm not sure what difference it makes, but I think the default

property
for a Range Object, including ranges that are cells, is the Item

Property.

Alan Beban

SunTzuComm wrote:

Each object has a default property, and for cell objects, it's

".Value".
I wouldn't trust myself to remember the default property of every
object, but if you know one for sure, you can safely omit it. In

fact,
doing so may make the code more efficient.

Regards,
Wes