-2

I am trying to convert VBA from an Excel Macro to C# to calculate a total loan amount where interest and a facility fee are capitalized to the loan balance, which then in turn means a higher interest and fee amount being capitalized as the loan increases, meaning a higher interest and fee cost etc etc.

I cannot replicate the circular reference which allows for enough iterations so that the delta in the change in interest and fee from the change in loan balance can be eliminated. Any help would be appreciated. Thanks CM25

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
CM25
  • 1

1 Answers1

1

This seems like a somewhat strange way of doing things, and I think the circular reference handling in Excel is a thing to be avoided not to use as a tool. Using some sort of limit theory to produce the value your calculation is approaching using the appropriate maths is going to be more rigourous than iterating over the thing however many times you think is enough.

However why can you not do exactly the same thing that Excel does in your code? You have a function that returns the fees based on an amount. Set up a loop for however many iterations you use in Excel which calls that function based on an amount which is increased by the result of the function each time.

For x = 1 to 100
  amount = amount + fees(amount)
Next x
Eric Nolan
  • 161
  • 1
  • 2