Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can anyone tell me how to create a vba function (I
believe I need some sort of loop expression) to 1)add 1 to each number and then 2) multiply each of the resulting values and then 3) subtract 1. I am trying to create a user-defined function to calculate the cumulative return of a series of numbers. For example: if the range of (4 in this case) numbers was .0291, -.0021, .0032 and .0337, then the answer to the function would be .07559 (1.0291*.9979*1.0132*1.0337 - 1) = .07559). Thank you. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jason,
this should do it. Public Function CRetn(rngValues As Range) As Double Dim rngCell As Range CRetn = 1 For Each rngCell In rngValues CRetn = CRetn * (1 + rngCell.Value) Next rngCell CRetn = CRetn - 1 End Function Robin Hammond www.enhanceddatasystems.com "Jason" wrote in message ... Can anyone tell me how to create a vba function (I believe I need some sort of loop expression) to 1)add 1 to each number and then 2) multiply each of the resulting values and then 3) subtract 1. I am trying to create a user-defined function to calculate the cumulative return of a series of numbers. For example: if the range of (4 in this case) numbers was .0291, -.0021, .0032 and .0337, then the answer to the function would be .07559 (1.0291*.9979*1.0132*1.0337 - 1) = .07559). Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I calculate Return on Investment in Excel | Excel Worksheet Functions | |||
how do you calculate annualised return? | Excel Worksheet Functions | |||
How to return the row # of an expression in specific array of cell | Excel Worksheet Functions | |||
Function to loop through a column and return a value based on an x | Excel Programming | |||
Loop through workbooks in a folder and return the value of cell M43 | Excel Programming |