I was wondering if there is a cleaner way to code this loop. Thanks in advance.
VBA Code:
Sub A()
Dim myLastRow As Long
Dim i As Long
Dim InvD As Date
InvD = InputBox("Invoice Date mm/dd/yy")
myLastRow = Cells(Rows.Count, "B").End(xlUp).Row
For i = 2 To myLastRow
If Range("I" & i).Value Like "Sub-Producer" & "*" Then
Range("I" & i).Value = "Sub-Producer Payment - " & Format(DateAdd("M", -1, Now), "MMMM YYYY")
Range("V" & i).Value = 23140
Range("E" & i).Value = InvD
Range("F" & i).Value = "=R[0]C[-1]+45"
End If
If Range("I" & i).Value Like "Royalty" & "*" And InStr(1, Range("D" & i).Value, 7) = 7 Then
Range("I" & i).Value = "Royalty Guarantee - " & Format(DateAdd("M", 0, Now), "MMMM YYYY")
Range("V" & i).Value = 23150
Range("E" & i).Value = InvD
Range("F" & i).Value = "=R[0]C[-1]+45"
End If
If Range("I" & i).Value Like "Royalty" & "*" And InStr(1, Range("D" & i).Value, 7) <> 7 Then
Range("I" & i).Value = "Royalty Payment - " & Format(DateAdd("M", 0, Now), "MMMM YYYY")
Range("V" & i).Value = 23150
Range("E" & i).Value = InvD
Range("F" & i).Value = "=R[0]C[-1]+45)"
End If
Next
End Sub