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
vba子过程或函数未定义怎么办
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 远方_流浪 2022-05-02 09:07关注
这个代码不够的,缺少一个
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
希望你能继续粘贴对应部分的代码或者说一下需求是什么,才能为你解决问题
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
- ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
- ¥50 sft下载大文阻塞卡死
- ¥15 机器人轨迹规划相关问题
- ¥15 word样式右侧翻页键消失
- ¥15 springboot+vue 集成keycloak sso到阿里云
- ¥15 win7系统进入桌面过一秒后突然黑屏
- ¥30 backtrader对于期货交易的现金和资产计算的问题
- ¥15 求C# .net4.8小报表工具
- ¥15 安装虚拟机时出现问题