Excel Formula: Return Zero When Columns Contain F Instead of P
Question details
The user needs a formula in column Y to return 0 when columns H, N, and T contain 'F' instead of 'P', while continuing its normal calculation otherwise.
- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Setting up a conditional formula that evaluates specific text values ('F' or 'P') across multiple columns before executing a VLOOKUP.
- Observed behavior
- The formula needs to output 0 when the text condition is met, overriding the default VLOOKUP calculation.
Verify that your data range (such as columns H through T) is structured consistently and that you have identified the correct normal calculation formula to execute when 'F' is not present.
Return Zero When More Than One 'F' Appears
Use this method if the presence of 'F' in more than one column within your data range should trigger a zero result.
This solution utilizes the COUNTIF function nested inside an IF statement to check how many times 'F' appears in the specified range. If it appears more than once, it returns 0; otherwise, it proceeds with the standard IFERROR and VLOOKUP calculation.
Click on the cell in column Y (e.g., Y14) where you want the formula result to appear.
Type the formula `=IF(COUNTIF(H14:T14,"F")>1,0,IFERROR(VLOOKUP(X14,ComPoint,2,TRUE),0))` into the formula bar.
Press Enter to execute. Click and drag the fill handle located at the bottom-right corner of the cell to apply the formula down the column.
Return Zero Only When All Three Columns Contain 'F'
Use this approach if you strictly need all the targeted columns to contain 'F' before returning a zero.
Calculate Complex Formulas Seamlessly with WPS Spreadsheet
WPS Spreadsheet fully supports Excel functions like IF, COUNTIF, and VLOOKUP. You can easily handle conditional data formatting, complex nested calculations, and large datasets seamlessly.
- 1. Open your file in WPS Spreadsheet: Launch WPS Office and open your workbook containing the data.
- 2. Select the target cell: Navigate to column Y where the conditional calculation is needed.
- 3. Enter the formula: Type your combined IF and COUNTIF formula and press Enter to evaluate.
- 4. Fill the column: Double-click the fill handle on the selected cell to automatically apply the formula to the rest of your data set.

Frequently Asked Questions
What if my target columns (H, N, T) are not contiguous and other columns might contain 'F'?
If columns between H and T might contain 'F' and should be ignored, do not use the range H14:T14. Instead, use addition to check specific cells: `=IF((H14="F")+(N14="F")+(T14="F")>=1, 0, IFERROR(VLOOKUP(X14,ComPoint,2,TRUE),0))`.
Why does the formula include IFERROR and VLOOKUP?
The `IFERROR(VLOOKUP(...), 0)` segment represents your normal calculation when the 'F' condition is not met. If the VLOOKUP fails to find a match, IFERROR catches the #N/A error and outputs 0, keeping your spreadsheet clean.
Can I change 'F' to evaluate other text values or numbers?
Yes. The COUNTIF function is highly flexible. You can replace 'F' with any text string (enclosed in quotes), numeric value, or even a cell reference that contains the condition you want to check.




