How to avoid circular reference when excel cell update
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 call开发者_如何学运维ing 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
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
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!
精彩评论