简体   繁体   中英

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 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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM