Serving the Quantitative Finance Community

 
User avatar
bansai

Volatile Functions from VBA

July 18th, 2002, 1:10 pm

Hi,I've a C++ function in a dll called via a VBA wrapper. When I enter the VBA wrapper in an Excel cell when Calculation is Manual, it gives me proper results.But if I hit F9 (or if I enter the function when Calculation is Automatic) the wrapper gets called scores of times and excel eventually crashes. To give you an idea, the C function is passed several arrays and performs some optimization which takes more than a few milliseconds.I've tried "Application.Volatile (False)" as the first line of my function, but it doesn;t prevent the above phenomenon. I use Excel 2002 on XP.Any help would be appreciated.bansai
 
User avatar
PinballWizard
Posts: 4
Joined: March 13th, 2002, 4:36 pm

Volatile Functions from VBA

July 18th, 2002, 3:28 pm

What else happens in that spreadsheet ? Do you have links to real-time feed ?
 
User avatar
bansai

Volatile Functions from VBA

July 18th, 2002, 4:01 pm

No real-time feeds yet. The function just Bootstraps a curve from given bond data.Equivalent bootstraper in VBA works fine, it's just the C++ version that seems to get throttled by too many calls in a short time.
 
User avatar
alvincho
Posts: 0
Joined: February 20th, 2002, 5:13 am

Volatile Functions from VBA

July 23rd, 2002, 2:20 pm

If your C++ function take arguments from other cells, Excel might cause it to calculate infinite times....Try to pass them via variables.
 
User avatar
bansai

Volatile Functions from VBA

July 23rd, 2002, 3:50 pm

I have a wrapper function in VBA to which I pass the ranges.This function then calls the C function in DLL after converting data to arrays.Still the problem persists.
 
User avatar
katmandu
Posts: 0
Joined: July 24th, 2002, 11:10 am

Volatile Functions from VBA

July 24th, 2002, 11:29 am

Application.Volatile tells Excel to recalculate your function every time a recalculation occurs, even if no arguments change.Try to comment-out the code of your function (i mean, return immeditely from C code with, for example, return 1.0 and look if the problem persists. But I think you should tell us something more about your function, the VBA code, the prototype in C etc...bye