Sub FillF()
Dim Cell As Range, rng As Range
Range("F2").FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-1],LIST!R3C2:R50C2,1,FALSE)=RC[-1]),IF(ISNA(VLOOKUP(RC[-1],LIST!R3C3:R50C3,1,FALSE)=RC[-1]),IF(ISNA(VLOOKUP(RC[-1],LIST!R3C4:R50C4,1,FALSE)=RC[-1]),"""",LIST!R3C4),LIST!R3C3),LIST!R3C2)"
Set rng = [F2]
Set rng = Range(rng, Cells(Cells(Rows.Count, 1).End(xlUp).Row, rng.Column))
If rng.Rows.Count = 1 Then
rng.Select
Else
rng.Cells(1, 1).AutoFill Destination:=rng, Type:=xlFillDefault
End If
For Each Cell In rng
Cell.Offset(0, 1) = 1
If Cell = "" Then
Cell.Interior.ColorIndex = 3
End If
Next Cell
End Sub
|