I am trying to find out the right if statement to use for this task:
if B5 is higher than C5 = 1 if B5 is within 2% higher than C5 = 2 if B5 is lower than C5
You can nest IF formulae:
=IF(condition2, 2, IF(condition1, 1, IF(condition3, 3, "error!")))
With your conditions, it looks something like:
=IF(AND(B5>(C5-(C5*2/100)), B5<(C5+(C5*2/100))), 2, IF(B5>C5, 1, 3))