m0_56612515 2022-05-02 01:56 采纳率: 100%
浏览 101
已结题

vba子过程或函数未定义怎么办

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

  • 写回答

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
    

    希望你能继续粘贴对应部分的代码或者说一下需求是什么,才能为你解决问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 11月28日
  • 已采纳回答 11月20日
  • 请提交代码 7月27日
  • 创建了问题 5月2日

悬赏问题

  • ¥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 安装虚拟机时出现问题