嵌套if但是操作符没有获取值

时间:2017-04-11 21:56:34

标签: excel-vba if-statement nested numeric vba

50

尝试这个

但它停止比较 尝试了很多方法来使这个代码工作 尝试了ELSEIF else并嵌套了如果......但是这些值只是停止匹配 enter image description here

1 个答案:

答案 0 :(得分:0)

您正在测试0.24(即24%)等数字与15之类的数字。您可能打算将它们与0.15(即15%)和0.25(即25%)等数字进行比较。

Private Sub Check()

  For rwIndex = 2 To 227
    If Len(Cells(rwIndex, 1).Value) > 0 Then
      If Cells(rwIndex, 3).Value < 6000 Then
        Cells(rwIndex, 6).Value = " Below 6M Is Not Acceptable"
      ElseIf Cells(rwIndex, 3).Value > 6000 And Cells(rwIndex,3).Value < 8000 Then
        Cells(rwIndex, 6).Value = " Not As Per Strategy"
      End If
      If Len(Cells(rwIndex, 5).Value) > 0 Then
        If Cells(rwIndex, 5).Value < 0 Then
          Cells(rwIndex, 6).Value = Cells(rwIndex, 6).Value & "  Negative Growth Is Inacceptable"
        ElseIf Cells(rwIndex, 5).Value < .15 Then
          Cells(rwIndex, 6).Value = Cells(rwIndex, 6).Value & "  Growth percent is Inappropriate"
        ElseIf Cells(rwIndex, 5).Value < .25 Then
          Cells(rwIndex, 6).Value = Cells(rwIndex, 6).Value & "  Growth Percent is OK"
        Else
          Cells(rwIndex, 6).Value = Cells(rwIndex, 6).Value & "  Growth percent Must be reviewed"
        End If
      End If
    End If
  Next rwIndex
End Sub