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

嘗試這種嵌套,但如果運營商不拾取值

,但是它停止比較 嘗試過很多辦法,使這個代碼工作 試圖ELSEIF else和嵌套,如果太...但這些值只是停止匹配 enter image description here

回答

0

您正在測試針對的數字,如15,你可能打算把它們比作數字,如0.15(即15%)和0.25(即25%)的數字,如0.24(即24%)。

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