Sunday 9 December 2012

Using VLOOKUP function with IF function

Last time we were discussing about complex or nested if function by which we calculated the grades of students. now we can useVLOOKUP function in place of nested if with the grades.
Just use like this
=IF(logical_test,"TRUE",VLOOKUP(lookupvalue,table_array,column_index_no,range_lookup))
by this you can reduce complexity of the previous function we used last time
this time we can use a table like (M1:N7) here with the reference of the grades.
and the function will be like the following

=IF(OR(AND(B2<50,COUNT(B2)=1),AND(C2<50,COUNT(C2)=1),AND(D2<50,COUNT(D2)=1)),"F",VLOOKUP(E2,M1:N7,2,TRUE))


which was

=IF(OR(AND(B2<50,COUNT(B2)=1),AND(C2<50,COUNT(C2)=1),AND(D2<50,COUNT(D2)=1)),"F",IF(E2>89,"A",IF(E2>79,"B",IF(E2>69,"C",IF(E2>59,"D",IF(E2>49,"E","F"))))))

if we use nested IF.

Another thing you must need to know when you are going to use VLOOKUP function scrolling down for other records is to use the absolute value for the table array. this time the formula should be like the following
=IF(OR(AND(B2<50,COUNT(B2)=1),AND(C2<50,COUNT(C2)=1),AND(D2<50,COUNT(D2)=1)),"F",VLOOKUP(E2,$M$1:$N$7,2,TRUE))

so, you will decide which one you will use..



No comments:

Post a Comment