Use Literal Text P1 in an Excel IF Formula
Question details
The user needs to compare a cell value with the literal text P1 in an Excel formula without Excel interpreting P1 as a cell reference.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Creating an IF formula that returns 1 only when cell D2 contains P1 and other cells meet specified numeric conditions.
- Observed behavior
- Excel treats an unquoted P1 value as a cell reference instead of text.
Confirm that P1 is the exact text stored in the cell, including any spaces or punctuation. Text constants in Excel formulas must be enclosed in straight double quotation marks.
Put P1 in double quotation marks in the IF formula
Use this method when P1 is a text value that your formula must compare against rather than a worksheet cell reference.
Double quotation marks tell Excel to treat P1 as literal text. Leave cell references such as D2, F2, S2, and Q2 without quotation marks.
Click the cell where you want the result of the IF formula to appear.
Type or edit the formula as =IF(AND($D2="P1",F2=1,S2=1,Q2=1),"1","0").
Press Enter. Excel returns 1 when D2 equals the text P1 and F2, S2, and Q2 each equal 1; otherwise, it returns 0.

Compare Text Values Such as P1 in WPS Spreadsheets Formulas
WPS Spreadsheets supports the same quoted-text formula syntax, so you can compare a cell with a literal value such as "P1" and calculate results with familiar IF and AND functions.
- 1. Open the spreadsheet in WPS Spreadsheets: Launch WPS Office and open the Excel workbook from the Home screen or select Menu > Open.
- 2. Select the result cell: Click the cell where the formula result should be displayed.
- 3. Enter the formula with quoted text: In the formula bar, enter =IF(AND($D2="P1",F2=1,S2=1,Q2=1),"1","0").
- 4. Apply the formula: Press Enter, then drag the fill handle down if you need to apply the formula to additional rows.

Frequently Asked Questions
Why does Excel treat P1 as a cell reference?
Excel recognizes P1 as a valid cell address: column P, row 1. Put it in double quotation marks as "P1" when you mean the text value.
Should numbers in an Excel comparison be enclosed in quotation marks?
No. Use F2=1 for a numeric comparison. Use quotation marks only when comparing text, such as D2="P1".
How can I return a number instead of text from an IF formula?
Remove the quotation marks around the output values: =IF(AND($D2="P1",F2=1,S2=1,Q2=1),1,0). This returns numeric 1 or 0 rather than text.
What if the cell may contain lowercase p1 instead of P1?
Standard Excel equality comparisons are not case-sensitive, so D2="P1" also matches p1. Use the EXACT function if case sensitivity is required, for example EXACT(D2,"P1").




