Dear sir,
Please debug and compile the following code I am using visual basic 6.5
Code:
Sub Frontier_Builder()
SolverReset
Application.ScreenUpdating = False
'Finding Maximum Surplus
    SolverOk SetCell:="$K$38", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$18:$B$27"
    SolverAdd CellRef:="$B$28", Relation:=2, FormulaText:="1"
    SolverAdd CellRef:="$B$18:$B$27", Relation:=1, FormulaText:="Optimal_Mix_Max"
    SolverAdd CellRef:="$B$18:$B$27", Relation:=3, FormulaText:="Optimal_Mix_Min"
    SolverAdd CellRef:="$H$31:$H$33", Relation:=1, FormulaText:="$I$31:$I$33"
    SolverOptions MaxTime:=1000, Iterations:=1000, Precision:=0.00000001, _
        AssumeLinear:=False, StepThru:=False, Estimates:=2, Derivatives:=2, _
        SearchOption:=1, IntTolerance:=0.000005, Scaling:=False, Convergence:=0, _
        AssumeNonNeg:=False
    Solution = SolverSolve(True)
MaxSurplus = Range("Surplus").Value
SolverReset
'Finding Minimum Surplus Volatility and its Surplus
    SolverOk SetCell:="$K$36", MaxMinVal:=2, ValueOf:="0", ByChange:="$B$18:$B$27"
    SolverAdd CellRef:="$B$28", Relation:=2, FormulaText:="1"
    SolverAdd CellRef:="$B$18:$B$27", Relation:=1, FormulaText:="Optimal_Mix_Max"
    SolverAdd CellRef:="$B$18:$B$27", Relation:=3, FormulaText:="Optimal_Mix_Min"
    SolverAdd CellRef:="$H$31:$H$33", Relation:=1, FormulaText:="$I$31:$I$33"
    SolverOptions MaxTime:=1000, Iterations:=1000, Precision:=0.00000001, _
        AssumeLinear:=False, StepThru:=False, Estimates:=2, Derivatives:=2, _
        SearchOption:=1, IntTolerance:=0.000005, Scaling:=False, Convergence:=0, _
        AssumeNonNeg:=False
    Solution = SolverSolve(True)
MinSurplus = Range("Surplus").Value
SolverReset
ReDim Asset_Mix_Array(1 To 10, 1 To 100) As Double
ReDim Frontier_Check_Array(1, 1 To 100) As Double
NextRow = 1
 Increment = (MaxSurplus - MinSurplus) / 100
     SolverOk SetCell:="$K$36", MaxMinVal:=2, ValueOf:="0", ByChange:="$B$18:$B$27"
     SolverAdd CellRef:="$B$28", Relation:=2, FormulaText:="1"
     SolverAdd CellRef:="$B$18:$B$27", Relation:=1, FormulaText:="Optimal_Mix_Max"
     SolverAdd CellRef:="$B$18:$B$27", Relation:=3, FormulaText:="Optimal_Mix_Min"
     SolverAdd CellRef:="$H$31:$H$33", Relation:=1, FormulaText:="$I$31:$I$33"
     SolverAdd CellRef:="$K$38", Relation:=2, FormulaText:="Desired_Surplus"
     SolverOptions MaxTime:=1000, Iterations:=1000, Precision:=0.00000001, _
         AssumeLinear:=False, StepThru:=False, Estimates:=2, Derivatives:=2, _
         SearchOption:=1, IntTolerance:=0.000005, Scaling:=False, Convergence:=0, _
         AssumeNonNeg:=False
 For i = MinSurplus To MaxSurplus - Increment Step Increment
     Range("Desired_Surplus").Value = i
     Solution = SolverSolve(True)
     If Solution = 0 Then
         Frontier_Check_Array(1, NextRow) = Range("Optimal_Mix_Total").Value
         Asset_Mix_Array(1, NextRow) = Range("Class1").Value
         Asset_Mix_Array(2, NextRow) = Range("Class2").Value
         Asset_Mix_Array(3, NextRow) = Range("Class3").Value
         Asset_Mix_Array(4, NextRow) = Range("Class4").Value
         Asset_Mix_Array(5, NextRow) = Range("Class5").Value
         Asset_Mix_Array(6, NextRow) = Range("Class6").Value
         Asset_Mix_Array(7, NextRow) = Range("Class7").Value
         Asset_Mix_Array(8, NextRow) = Range("Class8").Value
         Asset_Mix_Array(9, NextRow) = Range("Class9").Value
         Asset_Mix_Array(10, NextRow) = Range("Class10").Value
     NextRow = NextRow + 1
     End If
 Next
Range("Desired_Surplus").Value = MaxSurplus
Solution = SolverSolve(True)
Asset_Mix_Array(1, 100) = Range("Class1").Value
Asset_Mix_Array(2, 100) = Range("Class2").Value
Asset_Mix_Array(3, 100) = Range("Class3").Value
Asset_Mix_Array(4, 100) = Range("Class4").Value
Asset_Mix_Array(5, 100) = Range("Class5").Value
Asset_Mix_Array(6, 100) = Range("Class6").Value
Asset_Mix_Array(7, 100) = Range("Class7").Value
Asset_Mix_Array(8, 100) = Range("Class8").Value
Asset_Mix_Array(9, 100) = Range("Class9").Value
Asset_Mix_Array(10, 100) = Range("Class10").Value
Worksheets("Frontier Points").Range("B1:CW10").Value = Asset_Mix_Array
Application.ScreenUpdating = True
SolverReset
End Sub