Hi All,

I am quite stuck in an operation where I have to calculate a sum using circular reference.
Though in Excel , it's quite easy (or already managed by excel itself) to use circular reference but I am not sure how to implement this thing in C#.
The problem is like this:
I have to sum a whole range of cells and then two values in cells use the sum itself for their own calculation.that is,
if i have sum = num1 + num2 + num3 + num4,
then num2 = someVariable + sum/someVariable2;
and similarly num4 also uses sum in its value.
To start with I guess I should take sum = 0 and then calculate num2 and num4, that will give me a new sum that further can give me new value for two variables and finally I can get final sum.
But I am quite confused whether this approach is correct or not.

Please suggest!

Recommended Answers

All 2 Replies

In excel, you have the option to control the iterative calculation; by default it will only apply the circular reference 100 times or until the values change by no more than 0.001. You could emulate this behaviour with a while loop but there may be better way to approach it in C#.
Could you explain what you are trying to achieve with your circular reference? Maybe we can suggest a more efficient method if we know what you're trying to do.

Need Same Info how to do same in C# .Also formulas are not in sheet we are calculating same in c# and putting value in excel.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.