Hello People,
I am making an excel file to compare different sets of loans with eachother and calculate best alternatives given some parameters.
For allowing the calculations i need to make a table of total payments for the loan, already this is where things go wrong. For some reason i get rounding errors while making the table through VBA as compared to making the table in excel. The two pictures below show what happens:
In the first situation i calculate the table by using the sheet functions. Here are some more explanations about the formulas for each column:
A: just number 1 to infinity
B: Capital to be paid off at start of session (= Cell F from row -1)
C: Total annuity to be paid off (= cell J5 ; in this cell i used the function: =ABS(BET(J5;J3;J1)) to calculate this)
D: Intrest part to be paid off (= cell B of same row * cell (J5 ; in this cell i used the function: =((1+J4)^(1/12))-1 which calculates monthly intrest given a yearly intrest rate)
E: capital part to be paid off (= cell C of same row - cell D of same row)
F: Is rest capital after this period (= cell B of same row - cell E of same row) (this cell will be used in the next row)
loan-excelf.jpg
As you can see after 15 years (=180 monthly periods) the loan results to 0 where everything is calculated by excel ws
Below you can see the table that is derived from a VBA macro:
loan-vbaf.jpg
As you can see in period 180: the result is not 0 and I think this is because of rounding errors or not enough decimal spaces used in the VBA macro.
For generating this table, I actually did the same technique as described above in the ws functions, but now i am able to generate the table when n(=#years) increases (so if n=20 then there will be 240 monthly periods)
Below is the code i use to generate this table:
Is there anyone who understands my problem and has a solution for this problem?![]()
Please Login or Register to view this content.
I am aware that there may be faster calculation methods (maybe use range array instead of FOR LOOP?) for the VBA macro, but since i am only a beginner, i am already very happy that this works. I will finetune my code once i learn more about the effectiveness off VBA.
Thank you for your reaction
Bookmarks