2017-04-11 2 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 

versucht, dieseNested wenn aber Operatoren nicht richtig erfasst Werte

aber es nicht mehr zu vergleichen viele Möglichkeiten versucht, diesen Code Arbeit zu machen versucht ELSEIF anderes und wenn zu verschachtelt ... aber die Werte nur zu stoppen passende

Antwort

0

Sie testen Zahlen wie 0,24 (dh 24%) mit Zahlen wie 15. Wahrscheinlich möchten Sie sie mit Zahlen wie 0,15 (dh 15%) und 0,25 (dh 25%) vergleichen.

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 
Verwandte Themen