A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
The formula itself is syntactically valid. If it works in some rows but not others, despite the references being correct, I would first investigate the underlying cell values and Excel's calculation settings rather than the formula structure.
The most common causes are:
- Numbers stored as text: A cell may display
1but actually contain the text value"1". In that case,K7=1evaluates to FALSE. This can happen when data is imported or copied from another application. - Hidden decimal values: A cell may display
1but actually contain0.999999or1.000001. Excel displays the rounded value, but an exact comparison such asK7=1returns FALSE. - Manual calculation mode: Check Formulas → Calculation Options and make sure Automatic is selected. If Excel is in Manual mode, formulas may display outdated results until recalculated.
- Inconsistent cell contents: Check whether the affected cells contain leading or trailing spaces, formulas returning text, or other unexpected values.
Start by testing one row that works and one that doesn't. In an empty cell, enter:
=ISNUMBER(K7)
Then test:
=K7=1
And:
=O7=6
These tests will help determine whether Excel is evaluating the underlying values as expected.
You can also simplify the original formula using IFS:
=IFS(
AND(K7=1,O7=6),"Y1",
AND(K7=2,O7=7),"Y2",
AND(K7=3,O7=8),"Y3",
AND(K7=4,O7=9),"Y4",
AND(K7=6,O7=1),"Y6",
AND(K7=7,O7=2),"Y7",
AND(K7=8,O7=3),"Y8",
AND(K7=9,O7=4),"Y9",
TRUE," "
)
However, changing the formula structure is unlikely to fix the problem if the underlying values are inconsistent. I would investigate the data types and actual cell values first.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin