Fix Excel IF and AND Formula Returning Different Results for Cell References
Question details
The user's IF and AND formula evaluates incorrectly when comparing against a cell reference instead of a hardcoded numeric value.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Using logical functions (IF, AND) to check conditions based on referenced cell values.
- Observed behavior
- The formula returns a different result for the cell reference because the referenced value is being stored and recognized as text rather than a number.
Verify whether the referenced cell is formatted as Text, contains a hidden leading apostrophe, or is unexpectedly left-aligned, as these indicate the number is stored as text.
Use the VALUE Function to Convert Text to Numbers
Wrap the cell reference in the VALUE function to force Excel to treat the text-formatted cell as a number during the calculation.
When numbers are imported or typed with text formatting, logical operators will not consider them equal to a true number. The VALUE function instantly resolves this mismatch within the formula itself without altering the source data.
Click on the cell containing your problematic IF and AND formula.
Click into the formula bar to modify your existing formula.
Wrap the referenced cell with the VALUE function. For example, change E2=$F$1 to E2=VALUE($F$1). Your full formula should look similar to: =IF(AND(E2=VALUE($F$1), B2<>3002010102), -C2+D2, 0).
Press Enter to execute the formula. The logical comparison will now successfully evaluate the referenced cell as a number.

Remove Leading Apostrophe and Fix Cell Alignment
Manually clean the source cell by removing any hidden characters that force the number to behave as text.
Effortlessly Troubleshoot Formulas in WPS Spreadsheet
WPS Spreadsheet provides intuitive error checking and seamless formula evaluation, making it easy to spot formatting inconsistencies like numbers stored as text.
- 1. Open your workbook: Launch WPS Spreadsheet and open the file containing the formula error.
- 2. Spot the formatting warning: Look for a small green triangle in the upper-left corner of your referenced cell, which indicates a number stored as text.
- 3. Access the warning menu: Click the warning icon that appears next to the selected cell.
- 4. Convert to number: Select 'Convert to Number' from the dropdown menu. Your IF and AND formulas will automatically recalculate with the correct results.

Frequently Asked Questions
Why does my Excel formula work with a typed number but not a cell reference?
This usually happens because the typed number in your formula is recognized as a numeric value, while the data in the referenced cell is formatted or stored as text. Excel treats the text string '100' differently than the number 100.
How can I easily tell if a number is formatted as text?
Numbers formatted as text are typically left-aligned by default, whereas true numbers are right-aligned. Additionally, you might see a leading apostrophe in the formula bar or a small green triangle in the upper-left corner of the cell warning you of the formatting.
What does the VALUE function do in Excel formulas?
The VALUE function takes a text string that represents a number and converts it into a mathematical number. This allows logical functions like IF and AND to compare the values accurately without returning false errors.
Can I convert an entire column of text to numbers at once?
Yes. You can select the entire column, click the warning icon that appears, and choose 'Convert to Number'. Alternatively, navigate to the Data tab, click 'Text to Columns', and simply click 'Finish' to convert the whole column instantly.




