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

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日

悬赏问题

  • ¥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应用,多线程