Question : Using If and Vlookup in a VBA routine

How could you use an If and Vlookup statement together in VBA

Example:
=IF(A2="","",IF(ISNA(VLOOKUP(A2,SheetName!A:C,2,FALSE)),"Not Found",VLOOKUP(A2,SheetName!A:C,2,FALSE)))

Answer : Using If and Vlookup in a VBA routine

You can try something like this..
1:
2:
3:
4:
5:
6:
7:
8:
Sub EE()
Dim i As Integer
For i = 2 To 100
    Range("E" & i).FormulaR1C1 = _
        "=IF(R[1]C[-4]="""","""",IF(ISNA(VLOOKUP(R[1]C[-4],SheetName!C[-4]:C[-2],2,FALSE)),""Not Found"",VLOOKUP(R[1]C[-4],SheetName!C[-4]:C[-2],2,FALSE)))"
    Range("E" & i) = Range("E" & i).Value
Next
End Sub
Random Solutions  
 
programming4us programming4us