Excel VBA formulas for Spreadsheet by Sharath Kumar Peechara - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Exercise 15: Auto recalculate

 

To create this Function, execute the following steps

  1. Open Excel VBA (Alt + F11)
  2. Insert a New Module
  3. In the Project Explorer, double click on the Module
  4. Add the following code line:

Use the Application.Volatile True statement in Excel VBA function code lines to force the formula to recalculate, Insert the below code in a New Module.

img28.png

In This the code line Application Volatile True forces the function to recalculate every time the cell or range value changes, the new UDF (User Defined Function) with name Qtravg recalculate’s every time.

img29.jpg

In Cell F2 Type

= Qtravg()

2. Use Excel sheet options

  1. Press Ctrl + ALT + F9 in sheet
  2. Press F9 to recalculate entire spreadsheet