I haven't used excel for years, so I'm not sure as to the exact syntax, but you can you nested if-else statements to achieve this sort of thing. i.e. something to the effect of:
if (B5 is within 2% higher than C5)
print 2
else if (B5 is higher than C5)
print 1
else
print 3