Sub DEA1()
'Declare DMUNo as integer. This DMUNo represents the DMU under
'evaluation. In the example, DMUNo goes from 1 to 15
Dim DMUNo As Integer
For DMUNo = 1 To 15
'set the value of cell E18 equal to DMUNo(1,2,...,15)
Range("E18") = DMUNo
'Run the Solver model. The UserFinish is set to True so that
'the Solver Results dialog box will not be shown
SolverSolve UserFinish:=True
'Place the efficiency into column J
With Range("J1" & DMUNo + 1) = Range("F19")
'Select the cells containing the optimal lambdas
Range("I2:I16").Select
'Copy the selected lambdas and paste them to row "DMUNo+1"
'(that is row 2,3,...,16) starting with column K
Selection.Copy
Range("K" & DMUNo + 1).Select
Selection. PasteSpecial Paste:=x1 PasteValues, Transpose:=True
Next DMUNo
End Sub
这个代码不够的,缺少一个 SolverSolve
,需要根据你的操作需求来定义的
代码中缺少一个 end with
当前代码重新整理为:
Sub DEA1()
'Declare DMUNo as integer. This DMUNo represents the DMU under
'evaluation. In the example, DMUNo goes from 1 to 15
Dim DMUNo As Integer
For DMUNo = 1 To 15
'set the value of cell E18 equal to DMUNo(1,2,...,15)
Range("E18") = DMUNo
'Run the Solver model. The UserFinish is set to True so that
'the Solver Results dialog box will not be shown
SolverSolve UserFinish:=True
'Place the efficiency into column J
With Range("J1" & DMUNo + 1) = Range("F19")
'Select the cells containing the optimal lambdas
Range("I2:I16").Select
'Copy the selected lambdas and paste them to row "DMUNo+1"
'(that is row 2,3,...,16) starting with column K
Selection.Copy
Range("K" & DMUNo + 1).Select
Selection.PasteSpecial Paste:=x1PasteValues, Transpose:=True
End With
Next DMUNo
End Sub
希望你能继续粘贴对应部分的代码或者说一下需求是什么,才能为你解决问题