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
希望你能继续粘贴对应部分的代码或者说一下需求是什么,才能为你解决问题
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
- ¥15 gdf格式的脑电数据如何处理matlab
- ¥20 重新写的代码替换了之后运行hbuliderx就这样了
- ¥100 监控抖音用户作品更新可以微信公众号提醒
- ¥15 UE5 如何可以不渲染HDRIBackdrop背景
- ¥70 2048小游戏毕设项目
- ¥20 mysql架构,按照姓名分表
- ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
- ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
- ¥15 linux驱动,linux应用,多线程