Total return function, vba

BJM23

New Member
Joined
Mar 17, 2011
Messages
20
Basically, I am trying to create a function that returns the total return for an array of numbers. Here is an example of the formula;

((1+.25/100)*(1+.5/100)*(1+1.5/100)-1)*100
The forumula in excel would look something like this;
=(Product(A1:C1/100+1)-1)*100 given A1=.25,B1=.5,C1=1.5

Function Totaltreturn(rngRange As Range)
Dim vbCell As Range

For Each vbCell In rngRange
Totalreturn = (Product((Totalreturn * vbCell) / 100 + 1) - 1) * 100

Next vbCell
End Function

I started this code but am an amateur to vba so I am probably missing something quite basic. Please let me know, thank you in advance for your help.
 
Why would it return zero if I have entered exactly what you have provided?

I don't know. Try stepping through the code and watch the values as it progresses. It shouldn't matter if you use Excel 2007.
 
Last edited:
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top