View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Breitenbach Dave Breitenbach is offline
external usenet poster
 
Posts: 30
Default Interest calculation

Here's what I came up with for automation:
Sample data in A2:C17 (see below)

column D is the interest formula which attempts to satisfy your rules (there
were a few questions I had on specs (I assumed that when there were several
days in a row with the same rate and balance, that the interest is calculated
on the last of those contiguous days, and nothing on the earlier days), but
maybe you can modify for any small differences), starting in D3:

=IF(AND(B3=B2,C3=C2),IF(AND(B4=B3,C4=C3),"",
(ROUND(((SUMPRODUCT(--($B$1:B2=B3),
--($C$1:C2=C3),--($D$1:D2=""),--($F$1:F2=F3),($C$1:C2))+C3)
*B3/360/(SUMPRODUCT(--($B$1:B2=B3),--($C$1:C2=C3),
--($D$1:D2=""),--($F$1:F2=F3))+1)),2)*
((SUMPRODUCT(--($B$1:B2=B3),--($C$1:C2=C3),
--($D$1:D2=""),--($F$1:F2=F3))+1)))),IF(AND(B4=B3,C4=C3),
"",ROUND(C2*B3/360,2)))

[I entered carriage returns in case that made it easier to view]

column E is a counter formula (starting from cell E3) that is used in the
formula in column D to assure that multiple noncontiguous occurrences of the
same combination of balance and rate are ignored during the combination for
the case where it needs to compute more than one days' interest:

=IF(OR(B3<B2,C3<C2),F2+1,F2)

Column

A B C D E
[cell A1] RATE balance interest counter
2 1/1/2006 0.0500 50,000 0
3 1/2/2006 0.0500 50,000 13.88 0
4 1/3/2006 0.0400 50,000 5.56 1
5 1/4/2006 0.0400 55,000 2
6 1/5/2006 0.0400 55,000 2
7 1/6/2006 0.0400 55,000 18.33 2
8 1/7/2006 0.0500 55,000 3
9 1/8/2006 0.0500 55,000 15.28 3
10 1/9/2006 0.0560 60,000 8.56 4
11 1/10/2006 0.0540 60,000 9.00 5
12 1/11/2006 0.0500 50,000 6
13 1/12/2006 0.0500 50,000 13.88 6
14 1/13/2006 0.0550 60,000 7
15 1/14/2006 0.0550 60,000 18.34 7
16 1/15/2006 0.0540 61,000 9.00 8
17 1/16/2006 0.0540 50,000 9.15 9

My resulting Interest numbers are in column D.

Note:
Some causes of small interest differences could be computing interest in
arrears (using previous day's rate) vs. in advance (current day's rate)

hth,
Dave