Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
loops
I am a beginner programmer and I am trying to understand looping to optimize
a investment portfolio with 3 types of assets S, B & C. Does anyone have experience with such a routine? I want to find the optimal weights for this portfolio by changing each asset wieght. A portfolio cant hold more than 100%. In other words, what weights will optimize my return? i.e. S = 70%, B = 25% and C = 5% Total (S + B + C) cant exceed 100%. Therefore I am looping 3 different variables. I have tried a couple of methods but keep getting errors. Does anyone have a template for something similar I can try to work through?? ANy help is much appreciate! Capp |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
loops
Run this with a blank sheet active and see if it gives you some ideas:
Sub AF() Dim i As Long, s As Long Dim b As Long i = 1 Cells(i, 1).Resize(1, 3).Value = Array("s", "b", "c") For s = 1 To 100 For b = 0 To 100 - s i = i + 1 Cells(i, 1) = s Cells(i, 2) = b Cells(i, 3) = 100 - (b + s) Next Next End Sub -- Regards, Tom Ogilvy "Capp" wrote in message ... I am a beginner programmer and I am trying to understand looping to optimize a investment portfolio with 3 types of assets S, B & C. Does anyone have experience with such a routine? I want to find the optimal weights for this portfolio by changing each asset wieght. A portfolio cant hold more than 100%. In other words, what weights will optimize my return? i.e. S = 70%, B = 25% and C = 5% Total (S + B + C) cant exceed 100%. Therefore I am looping 3 different variables. I have tried a couple of methods but keep getting errors. Does anyone have a template for something similar I can try to work through?? ANy help is much appreciate! Capp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
loops???? | Excel Worksheet Functions | |||
loops ... | Excel Programming | |||
Using For - Next Loops in VB | New Users to Excel | |||
for each loops | Excel Programming | |||
help with loops | Excel Programming |