loops

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top