[AccessD] OT: Excel VBA - Formula versus Value

Bill Benson (vbacreations) vbacreations at gmail.com
Sun May 23 06:29:39 CDT 2010


Well it is mutual - I never thought about what you pointed out!

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Asger Blond
Sent: Sunday, May 23, 2010 7:25 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] OT: Excel VBA - Formula versus Value

You are right of course: when *reading* the content of a cell it makes a
great difference - just didn't come to my thoughts. Thank you for pointing
out!
Asger

-----Oprindelig meddelelse-----
Fra: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] På vegne af Bill Benson
(vbacreations)
Sendt: 23. maj 2010 12:47
Til: 'Access Developers discussion and problem solving'
Emne: Re: [AccessD] OT: Excel VBA - Formula versus Value

Good point, it certainly seems so when assignments go the direction you have
written. Anytime a formula is written into a cell it is evaluated, same as
when you enter it in the formula window - unless the cell is formatted as
text, then neither is evaluated.

Since you have been coding in VBA a long while I know you are not asserting
this about the other direction:

   MyVar =  [A1].Value 
Vs
   MyVar =  [A1].Formula

Very different.

Might need to be careful at times using Range this way without a an object
qualifier, such as a reference to a worksheet ... unless you really want
Activesheet.


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Asger Blond
Sent: Saturday, May 22, 2010 7:57 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] OT: Excel VBA - Formula versus Value

Writing Excel VBAs for years I've always used the property Value, and
suddenly it strikes me:  What's the difference between Formula and Value?

Below examples lead to same result:

Range("A1").Value = "Test" 

Range("A1").Formula = "Test" 

Range("A1").Value = "=B1+B2" 

Range("A1").Formula = "=B1+B2"

Is Value versus Formula only a matter of code readability?

 

Asger

 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.819 / Virus Database: 271.1.1/2887 - Release Date: 05/22/10
02:26:00


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.819 / Virus Database: 271.1.1/2887 - Release Date: 05/22/10
14:26:00






More information about the AccessD mailing list