[AccessD] OT: Excel VBA - Formula versus Value

Bill Benson (vbacreations) vbacreations at gmail.com
Sun May 23 05:46:49 CDT 2010


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





More information about the AccessD mailing list