#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dot value

I have noted that the MVP members always include .Value when reffering to a cell. eg.

if activecell.value= 5 then

for years I would have just used (and have never had any problems) with.

if activecell=5


What are the bennifits in specifying "Value"?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default dot value

Stuart,

Invariably, an object has a default property. If you do not specify a property, the default is assumed.

I personally try to avoid the default and specify all properties. I find this causes less confusion, is more explanatory, and is likely to cut down on simple errors.

As you may have guessed. Value is the default property of the Range object, of which Activecell is an instance.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message ...
I have noted that the MVP members always include .Value when reffering to a cell. eg.

if activecell.value= 5 then

for years I would have just used (and have never had any problems) with.

if activecell=5


What are the bennifits in specifying "Value"?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default dot value

Hi

If you don't spesify anything, the default property will be used. For a cell that's Value. So you don't have to use .value to enter a number or a text into a cell.

The good thing is that's a good habit, you know what you do and the code is explaining what's happening so you can read and maintain it afterwards without knowing what the default property of just everything might be.

You may already know this, but just in case: If you do something like

Activecell = Activecell

you might think that nothing changes and that you're just confirming where and what the active cell is. Well, not so. Do it in a cell containing a formula and see what happens.

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Stuart" skrev i melding ...
I have noted that the MVP members always include .Value when reffering to a cell. eg.

if activecell.value= 5 then

for years I would have just used (and have never had any problems) with.

if activecell=5


What are the bennifits in specifying "Value"?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default dot value

as mentioned, Value is the defualt property, and while it
can be omitted in VB6/VBA, using it does make code more
legible.

However .NET object have no defualt value. If your
current code uses the .Default methods & properties, then
it will make re-factoring your code so much easier.


Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
I have noted that the MVP members always include .Value

when reffering to a cell. eg.

if activecell.value= 5 then

for years I would have just used (and have never had any

problems) with.

if activecell=5


What are the bennifits in specifying "Value"?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"