Dear All, Kindly please provide me a macro code for the below algorithm which is used to calculate compound interest. Also i would appreciate if you can provide me details on how to use that macro.
Int_Rate(Principle p, ROI r,Days d) { int i; if(r =<x && d<= 30) { i = p * ( r/12) return i; } /* the above IF calculates the interest for minimum 30 days if the interest rate is below x% per annum */ else if(r > x && r <= y && d<= 15) { i = (p * ( r/12))/2 return i; } /* the above IF calculates the interest for minimum 15 days if the interest rate is above x% and below or equal to y% per annum */ else if(r > x && r<=y && d < 30) { i = ((p * ( r/12))/30)*d return i; } /* the above IF calculates the interest for n days in a month(more than 15) if the interest rate is above x% and less than or equal to y% per annum*/ else if(r> y && d >30) { z = (d/30) /* Any number having a decimal should be converted to next immedate integer .Ex: No.s like 1.01, 1.2 ,1.3,1.66 ,1.99 should be taken as z = 2.*/ p1=p; for (j=1; j<=z ; j=j+1 ) { i = p1 * ( r/12) p1=p1+i } i = p1 -p return i; } /* the above IF calculates the interest for n months if the interest rate is above y% per annum.Ex for 95 days ,n =4; for 59 days ,n=2; months compounded monthly*/ else if(r==x && d>30) { if( (d/15) == even) /* d/15 should be converted to next immediate integer if it is having a decimal.ex 3.01,3.02,3.99 should be converted to 4 */ { z = (d/30) /* Any number having a decimal should be converted to next immedate integer .Ex: No.s like 1.01, 1.2 ,1.3,1.66 ,1.99 should be taken as z = 2.*/ p1=p; for (j=1; j<=z ; j=j+1 ) { i = p1 * ( r/12) p1=p1+i } i = p1 -p return i; } /* the above IF calculates the interest for n months if the interest rate is equal to x% per annum.Ex for d=60 days ,z =2; for d=85 days ,z=3; months compounded monthly*/ else if( (d/15) == odd) /* d/15 should be converted to next immediate integer if it is having a decimal.ex 4.01,4.02,4.99 should be converted to 5 */ { d1=((d/15)-1) * 15 /* d/15 should be converted to next immediate integer if it is having a decimal.ex 4.01,4.02,4.99 should be converted to 5.So now for example if d=63,d/15=5(as 4.02 is converted to 5),d1=5-1=4 */ z=d1/2 /* for 2 months */ p1=p; for (j=1; j<=z ; j=j+1 ) { i = p1 * ( r/12) p1=p1+i } i1 = p1 -p i 2= (p1 * ( r/12))/2 i=i1+i2 return i; } /* the above IF calculates the interest for n months if the interest rate is equal to x% per annum.Here the number of days are odd multiples of 15 when converted to nearest integer.Ex for d=65 days,d1=60 days ,z =2; for d=95 days, d1=90 days ,z=3; months compounded monthly*/ } } Thanks for your help please guide me Thanks & Regards Niraj Kothari --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---