2017-04-11 7 views
1
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" 
     Else: 
      If Cells(rwIndex, 5).Value < 15 Then 
      Cells(rwIndex, 6).Value = Cells(rwIndex, 6).Value & " Growth percent is Inappropriate" 
      Else: 
      If 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 
     End If 
    End If 
    Next rwIndex 
End Sub 

...하지만 값은 일치 중지 enter image description here중첩 된 연산자 따기하지 그러나 경우에 값이</p> <p>있지만 이 코드를 작동하게하는 여러 가지 방법을 시도 비교 중지 다른 ELSEIF을 시도하고 너무 경우 중첩 노력

답변

0

15와 같은 숫자에 대해 0.24 (즉 24 %)와 같은 숫자를 테스트하고 있습니다. 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