Home > Software engineering >  Several groups of punctuation is generated by VBA efficient frontiers, running problems, strives for
Several groups of punctuation is generated by VBA efficient frontiers, running problems, strives for

Time:09-27

Learn to investment portfolio optimization here, want to use vba to make several groups of points, with the method of tracing point draw a frontier
Way is for the coordinates, given a yield, and then planning, it is concluded that the minimum variance portfolio under the condition of

The following is the younger brother to write the code

Sub no_short_EF ()

Dim MinDeviation As Double, Step As Double
Dim I As an Integer, j As Integer
Dim counter As Integer

Counter=Range (" M3 ")
Step=Range (" the M4 "). The Value


For j=1 To counter
[J4]. Offset (j - 1, 0). The Value=https://bbs.csdn.net/topics/Step * (j - 1)
Next
To counter the For I=1

SolverReset
SolverOK SetCell:=Range (" M6 "). The Value, _
MaxMinVal:=2, _
ByChange:=Range (" M10 ", "M29")
Solveradd CellRef:=Range (" M10 ", "M29"), _
Function:=3, _
FormulaText:=0
Solveradd CellRef:=Range (" ("). The Value, _
Function:=2, _
FormulaText:=1
Solveradd CellRef:=Range (" M7 "). The Value, _
Function:=2, _
FormulaText:=[J4]. Offset (I - 1, 0). The Value
SolverSolve UserFinish:=True
[i2]. Offset (I - 1, 0)=Range (" M6 "). The Value

Next

End Sub



Coordinate point but the result, as shown in the figure, seems to be in the loop of planning execution, the younger brother novice vba, it doesn't understand, ask everybody to help grateful

CodePudding user response:

To learn in the vba IDE, set breakpoints and single-step tracking code window, window output value of the current relevant variables debugging immediately,
  •  Tags:  
  • VBA
  • Related