PC Review


Reply
Thread Tools Rate Thread

Array Math in UDF

 
 
stephen.h.dow@gmail.com
Guest
Posts: n/a
 
      26th Mar 2008
Here's a tricky one that I just can't seem to wrap my head around...

I'm looking at recovery rates (could be for chemical reactions,
finanical transaction, etc) over time. In each period I "lose" a
certain quantity, but know that I will recover a predetermined portion
(say 45%) over a predetermined recovery curve (4.5% in current period,
9%, 18%, 4.5%, and 9% in period +4). I'm trying to create a UDF that
will calculate the total recovered for a given period. The recovery
for a given period will include the 4.5% of the "loss" in the current
period plus and recovered amounts from prior period, if applicable.

A simplified example is:
Period | Loss | Recovered Amount
1 | 100 | 4.5
2 | 200 | 18 (9%*100 + 4.5%*200)
3 | 100 | 40.5
4 | 0 | 49.5
5 | 0 | 36
6 | 0 | 22.5
7 | 0 | 9

So, the total recovered amount is 180, which is 45% of the 400 that
was lost.

If anyone help me get started or point me to something that solved for
a similar problem, I would greatly appreciate it.

Thanks,
Steve
 
Reply With Quote
 
 
 
 
stephen.h.dow@gmail.com
Guest
Posts: n/a
 
      26th Mar 2008
I seem to have answered my own problem, so thought I'd post the
solution:

Function Recovery(RecovArray, LossArray, PeriodArray, Period As
Single) As Double
Dim Element As Variant
Dim SumRecov As Double
Dim Iteration As Integer
Dim LossOffset As Integer
Dim CalcPeriod As Integer

Iteration = 0
LossOffset = Period - 1

Do
SumRecov = SumRecov + RecovArray(Period - Iteration) *
LossArray(Period - LossOffset)
Iteration = Iteration + 1
LossOffset = LossOffset - 1
CalcPeriod = CalcPeriod + 1
Loop Until CalcPeriod = Period

Recovery = SumRecov

End Function

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the math behind array function yshridhar Microsoft Excel Misc 2 7th Dec 2007 10:44 AM
Matrix Math using LOOKUP inside Array {} Function =?Utf-8?B?RXhjZWxNb25rZXk=?= Microsoft Excel Worksheet Functions 4 15th Feb 2007 11:10 PM
How Math.Cos & Math.Sin is implemented? Morgan Cheng Microsoft C# .NET 13 17th Oct 2006 04:03 AM
efficiency: database functions vs. math functions vs. array formula nickname Microsoft Excel Misc 2 14th Jul 2006 04:26 AM
excel math forumla? (simple math problem inside for math people!) Jason Microsoft Excel Discussion 3 16th Feb 2006 10:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:36 PM.