#REF generally means there is something wrong with the range it is trying to look in (usually it means the cell(s) originally referenced in the formula have been deleted)
Do you see #REF in the formula itself (e.g., LOOKUP(B2,#REF,2,false), or just in the result?
If you know the range you want...