Quick Find: Search for:
Free Resources
from FMS
 

Demos

Email Newsletter

Technical Papers

Tips and Techniques

Blog

Links

Book Recommendations

View all FMS products for Microsoft AccessMicrosoft Access Resource Center

 

 

"Thank you! Thank you!
I just finished reading this
document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.
" 
- Darren D.
 
  

 

Excel Automation: More than just a formula

Provided by:  FMS Development Team

When you make a call to the Formula property, be aware of the results that are returned. At first, you would expect to either get an empty string or the cell's formula. However, this is not the case.

 

Here is what could be returned:

 

  1. If the cell contains a constant, this property returns the constant.

  2. If the cell is empty, this formula property returns an empty string.

  3. If the cell contains a formula, the formula property returns the formula as a string in the same format that would be displayed in the formula bar (including the equal sign).

In your code, to ensure that you are getting a formula returned, you need to check for the "=" character.

Run the sample code below to see the results in the immediate window. Add the code to the click event of a button. Make sure you set the references to a version of Excel (97, 2000, 2002, and 2003).

Here are the results returned in the immediate window:

The formula property in cell 'A1' says: 10
The formula property in cell 'A4' says: Sum(All Parts)
The formula property in cell 'A6' says: =SUM(A1:A4)

Sample Code

Return to the tips page.

Contact Us  l   Web questions: Webmaster   l   Copyright © 2009 FMS, Inc., Vienna, Virginia

Celebrating 23 Years of Software Excellence