I have a column of codes and I specifically want to extract ANY of these codes with Excel’s IF function.
I wrote this code and it did not work:
How can I use the IF function or other function to pick out any of the above codes?
EDIT: the code itself works but it does not return 1 when it hits any of the specified codes.
Check the value in cell O2. If it is text, then your formula will work. If the value in cell O2 is a number like 6122, then your formula will not work, since it is explicitly looking for a text value of “6122” and the other text values.
Data type matters. The text “6122” is not the same as the numeric value 6122.
You can alleviate the issue by coercing the value in O2 to a number and forcing a numeric comparison with
(if your regional settings use the semicolon ; as a list separator, please replace the commas in the above formula with semicolons)
This will work if O2 is either text or numeric. The values to compare with are numbers.
So, determine what data type is stored in cell O2 and make sure that you compare it with a suitable data type in your formula.