I created a if and, but need to add a loop. Cannot get a loop to work.
Sub IfAnd()
If Range("j2") = "9-99-9998" And Range("f2") <> 2 Then
Range("k2").Value = "Indirect"
Else
If Range("j2") = "9-99-9998" And Range("F2") = 2 Then
Range("k2").Value = "IndirectOT"
Else
If Range("j2") <> "9-99-9998" And Range("F2") <> 2 Then
Range("k2").Value = "Direct"
Else
If Range("j2") <> "9-99-9998" And Range("F2") = 2 Then
Range("k2").Value = "DirectOT"
End If
End If
End If
End If
End Sub
created an array, but did not work
>Solution :
Option Explicit
Sub IfAnd()
Dim r As Long, s As String
For r = 2 To 3
If Cells(r, "J") = "9-99-9998" Then
s = "Indirect"
Else
s = "Direct"
End If
If Cells(r, "F") = 2 Then
s = s & "OT"
End If
Cells(r, "K") = s
Next
End Sub