Private Sub cmdSolve_Click() Dim MPL As OptiMax Dim planModel As Model Dim varVect As VariableVector Dim subProduct As Subscript Dim subMonth As Subscript Dim result As Integer Dim rngSolution As Range Dim line As Integer Set MPL = New OptiMax MPL.WorkingDirectory = "c:\mplwin4" MPL.Solvers.Add "cplex65.dll" Set planModel = MPL.Models.Add("Planning") result = planModel.ReadModel("planning.mpl") If result > 0 Then MsgBox planModel.ErrorMessage Else planModel.Solve Range("B2").Value = planModel.Solution.ResultString Range("B4").Value = "Objective Value = " & _ planModel.Solution.ObjectValue Set varVect = planModel.VariableVectors("Production") Set subProduct = varVect.Subscripts("product") Set subMonth = varVect.Subscripts("month") line = 0 Set rngSolution = Range("B6:D42") varVect.MoveFirstPos Do While varVect.PosValid line = line + 1 rngSolution(line, 1).Value = subProduct.Value rngSolution(line, 2).Value = subMonth.ValueName rngSolution(line, 3).Value = varVect.Variable.Activity varVect.MoveNextPos Loop End If End Sub