VBA“;编译错误:没有If的Else;

VBA“;编译错误:没有If的Else;,vba,excel,debugging,Vba,Excel,Debugging,到目前为止还没有人的“解决方案”修复我的bug,有什么提示吗 我正在VBA中调试宏,出现以下错误: “编译错误: 否则不带If“ 关于如何解决这个问题有什么建议吗 以下是代码的重要部分: For Ind4 = 1 To iPlateNo Ind6 = Ind4 + 2 MeanComp = 0.6 * Cells(81, Ind6).Value For Ind5 = 1 To iMxRNo If Cells(Ind5, Ind6).Value < M

到目前为止还没有人的“解决方案”修复我的bug,有什么提示吗

我正在VBA中调试宏,出现以下错误:

“编译错误: 否则不带If“

关于如何解决这个问题有什么建议吗

以下是代码的重要部分:

For Ind4 = 1 To iPlateNo
    Ind6 = Ind4 + 2
    MeanComp = 0.6 * Cells(81, Ind6).Value
    For Ind5 = 1 To iMxRNo
        If Cells(Ind5, Ind6).Value < MeanComp Then Cells(Ind5, Ind6).Interior.Color = RGB(255, 0, 0)
'           If the cell value is less than the average highlight them red as outliers. (More likely: from pipettes that didn't release)
        ElseIf Cells(Ind5, Ind6).Value > MeanComp Then Cells(Ind5, Ind6).Interior.Color = RGB(7, 253, 56)
'           If the cell value is greater than the average highlight them green as outliers. (Unlikely unless )
        Else
        End If
    Next Ind5
Next Ind4
Ind4=1到iPlateNo的

Ind6=Ind4+2
平均值=0.6*个单元格(81,Ind6)。数值
对于Ind5=1至iMxRNo
如果单元格(Ind5,Ind6).ValueMeanComp然后Cells(Ind5,Ind6).Interior.Color=RGB(725356)
'如果单元格值大于平均值,则以绿色突出显示它们作为异常值。(不太可能,除非)
其他的
如果结束
下一个Ind5
下一个Ind4

更改代码的布局-

For Ind4 = 1 To iPlateNo
    Ind6 = Ind4 + 2
    MeanComp = 0.6 * Cells(81, Ind6).Value
    For Ind5 = 1 To iMxRNo
        If Cells(Ind5, Ind6).Value < MeanComp Then
        Cells(Ind5, Ind6).Interior.Color = RGB(255, 0, 0)
'           If the cell value is less than the average highlight them red as outliers. (More likely: from pipettes that didn't release)
        ElseIf Cells(Ind5, Ind6).Value > MeanComp Then
        Cells(Ind5, Ind6).Interior.Color = RGB(7, 253, 56)
'           If the cell value is greater than the average highlight them green as outliers. (Unlikely unless )

        End If
    Next Ind5
Next Ind4
Ind4=1到iPlateNo的

Ind6=Ind4+2
平均值=0.6*个单元格(81,Ind6)。数值
对于Ind5=1至iMxRNo
如果单元格(Ind5,Ind6)。值<平均值
单元格(Ind5,Ind6).Interior.Color=RGB(255,0,0)
'如果单元格值小于平均值,则以红色突出显示它们作为异常值。(更有可能:来自未释放的移液管)
其他细胞(Ind5,Ind6)。值>平均值
单元格(Ind5,Ind6).Interior.Color=RGB(725356)
'如果单元格值大于平均值,则以绿色突出显示它们作为异常值。(不太可能,除非)
如果结束
下一个Ind5
下一个Ind4
对于Ind4=1到iPlateNo
Ind6=Ind4+2
平均值=0.6*个单元格(81,Ind6)。数值
对于Ind5=1至iMxRNo
如果单元格(Ind5,Ind6)。值<平均值
单元格(Ind5,Ind6).Interior.Color=RGB(255,0,0)
其他细胞(Ind5,Ind6)。值>平均值
单元格(Ind5,Ind6).Interior.Color=RGB(725356)
如果结束
下一个Ind5
下一个Ind4
这似乎很好

编辑:删除了代码周围的子过程

您只需要在放置语句的代码中做一些小的更改
You just need to make the small change in the code that put the statement 
after then in the next line shown in the below code highlighted as bold.
For Ind4 = 1 To iPlateNo
Ind6 = Ind4 + 2
MeanComp = 0.6 * Cells(81, Ind6).Value
For Ind5 = 1 To iMxRNo
If Cells(Ind5, Ind6).Value < MeanComp **Then
Cells(Ind5, Ind6).Interior.Color = RGB(255, 0, 0)**
之后,在下面显示的代码中的下一行中突出显示为粗体。 对于Ind4=1至iPlateNo Ind6=Ind4+2 平均值=0.6*个单元格(81,Ind6)。数值 对于Ind5=1至iMxRNo 如果单元格(Ind5,Ind6).值<平均值**,则 单元格(Ind5,Ind6).Interior.Color=RGB(255,0,0)**
'如果单元格值小于平均值,则以红色突出显示它们作为异常值。 ElseIf细胞(Ind5,Ind6)。值>平均值>然后 单元格(Ind5,Ind6).Interior.Color=RGB(725356) 其他的 如果结束 下一个Ind5
Next Ind4

删除最后一个else:它对当前用户无效code@moffeltje谢谢,我不知道下一个Ind5应该是什么,但是我仍然有错误消息。这看起来编译得很好,但是我得到了错误消息:“运行时错误'438':对象不支持此属性或方法”。这与此问题有关吗?我在一个较大的宏中运行此操作,因此我去掉了私有子行和结束子行并插入了它。很抱歉,我将其放入编辑器中,需要添加似乎编译良好的子行,但随后我收到以下错误消息:“运行时错误‘438’:对象不支持此属性或方法”。这和这个问题有关吗?我不知道你剩下的代码。错误438发生在哪里?在我的宏开头附近的“Application.CalculationxlManual”行上。如果没有其余的代码,这是非常广泛的问题,很难诊断。@ThomasShera如果其中一个答案解决了您的问题,请单击它旁边的绿色复选标记将问题标记为已回答。
You just need to make the small change in the code that put the statement 
after then in the next line shown in the below code highlighted as bold.
For Ind4 = 1 To iPlateNo
Ind6 = Ind4 + 2
MeanComp = 0.6 * Cells(81, Ind6).Value
For Ind5 = 1 To iMxRNo
If Cells(Ind5, Ind6).Value < MeanComp **Then
Cells(Ind5, Ind6).Interior.Color = RGB(255, 0, 0)**