tags:

views:

138

answers:

3

Hi,

I'm writing a set of functions in c++ which can be called by excel. However, these functions are asynchronous, therefore no immediate return values available. Once a result is available I used a callback function through VBA which update the result to the relevant cell which called the functions.

But, here I'm having circular function calling problem, because when I update the cell. excel automatically call the original function once again. Please help me to get around this problem

Thank You

A: 

Without knowing more about the data flow of your program it's impossible to answer in detail. When are c++ functions called, what data is passed to them and when are you updating the relevant cell?

Regardless, how are you calling the C++ functions? If it's via VBA, try turning off automatic calculation:

MyWorkSheet.EnableCalculation = False

and then turning it back on at the end of the callback:

MyWorkSheet.EnableCalculation = True
gvkv
A: 

I have a similar problem.

I am in Excel and am writing a simple UDF. As one of its parameters, I pass the current cell reference. Which in my case is G2. I pass it in a variable called rParam2 (As String).

This is because the other cells I reference for values are dependent on where I start!

Anyway, I simply put: MsgBox rParam2

I get a circular error.

How can I get the value from rParam2 without causing an error ?

thanks,,

A: 

It is better, if you can put a code sample explaining what you are exactly trying to do.

what do you mean by

pass the current cell reference

if my understanding is correct, you are trying to pass return value of the function to the function itself again. This is a circular reference. because, when the function returns a value, the cell value get updated which then cause re-evaluate any function that has the updated cell reference as a input parameter which result in your function to call in a loop!

nimo