子行给出编译错误:未定义变量

时间:2015-06-19 19:20:37

标签: compilation

尝试运行我的代码后,我收到错误"compile error: variable not defined"并突出显示我的Sub行。以下是供参考的代码。

Sub RI_Processing()
    Dim i As Single
    Dim Output() As Single 'Define this dynamic array for the solver output

Process the DMSO data
    For i = 1 To 45 Step 1
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Activate
        RawData.Range("C10:C649") = Sheet1.Columns("i").Values
        SolverOk SetCell:="$E$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$2:$B$4", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverSolve
        Workbooks("Simulated Fresnel Function.xlsx").Activate
        Output(i, 1) = Sheet1.Range("B4").Values

    Next i

    i = 0

    ' Process the NaCl Data
    For i = 1 To 102 Step 1
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Activate
        RawData.Range("C10:C649") = Sheet2.Columns("i").Values
        SolverOk SetCell:="$E$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$2:$B$4", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverSolve
        Workbooks("Simulated Fresnel Function.xlsx").Activate
        Output(i, 2) = Sheet1.Range("B4").Values

    Next i

    i = 0

    ' Process the Sucrose data
    For i = 1 To 72 Step 1
        Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Activate
        RawData.Range("C10:C649") = Sheet3.Columns("i").Values 'Copies the data of all 'i' columns to raw data for solver
        SolverOk SetCell:="$E$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$2:$B$4", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverSolve 'Run solver
        Workbooks("Simulated Fresnel Function.xlsx").Activate
        Output(i, 3) = Sheet1.Range("B4").Values 'Put solver output to the matrix 'output' in the appropriate columns

    Next i

End Sub

0 个答案:

没有答案