Loop

  • Thread starter Thread starter oscarooko
  • Start date Start date
O

oscarooko

Hello,
I need a loop for my code. I have this code, but it will only check if
the conditions are true for the first row, assigns a grade for teh row,
and then it terminates. I need it to go through all rows irrespective
of "how many" they are. Someone help!

Sub Oscar()
Dim grade As String
Dim FICO As String
Dim Lien As String
Dim LTV As String
Dim DTI As String

FICO = Sheet3.Range("U2").Value
Lien = Sheet3.Range("AA2").Value
LTV = Sheet3.Range("S2").Value
DTI = Sheet3.Range("V2").Value

If (FICO > 700 And Lien = 1 And LTV < 90 And DTI <= 45) Or (FICO > 720
And Lien = 1 And LTV < 95 And DTI <= 45) Then

grade = "Prime"
Else

If (FICO > 650 And Lien = 1 And LTV < 95 And DTI <= 45) Or (FICO >= 680
And Lien = 1 And LTV < 95 And DTI <= 50) Or (FICO >= 680 And Lien = 2
And LTV < 95 And DTI <= 50) Then
grade = "AA"

Else
If (FICO >= 600 And Lien = 1 And LTV < 100 And DTI <= 50) Or (FICO >=
620 And Lien = 2 And LTV <= 95 And DTI <= 45) Then
grade = "A+"

Else: grade = "FAIL"


End If
End If
End If
Sheet3.Range("L2").Value = grade
End Sub
 
Dim Counter as Long

for counter = 0 to Sheet3.Range("U65000").End(XLUp).Row - 2

''all your code here

next counter

works for all rows where there is a value in U

add offset to all your range refernces

ie...Sheet3.Range("L2").Offset(counter,0).Value = grade
 
Back
Top