How to Include or Exclude Excel Cells from a SUM Formula
Question details
The user wants to selectively include or exclude specific cell values in a calculation without manually hiding rows or altering the main dataset structure.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating a total where certain values must be skipped dynamically based on user choice or a specific condition, like a date entry being present.
- Observed behavior
- The standard SUM function adds all numbers in a specified range unconditionally, requiring alternative functions to apply targeted inclusion criteria.
Determine whether you prefer manually toggling values on and off using a 1/0 helper column, or if you want to automatically trigger inclusion based on existing data, such as a date entry.
Use SUMPRODUCT with a 1 or 0 Helper Column
Create a helper column where 1 includes the adjacent value and 0 excludes it, then calculate the total using the SUMPRODUCT function.
This method is highly flexible because it allows you to manually flag exactly which cells should be part of the final sum without affecting hidden rows or changing your actual data values.
Create a new column directly next to the values you want to sum. For instance, if your values are in range A1:A6, use B1:B6 as the helper column.
Type '1' in the helper cells next to the values you want to include in the total, and '0' next to the values you want to exclude.
Select an empty cell for your total and enter the formula: =SUMPRODUCT(A1:A6,B1:B6).
Press Enter. The formula multiplies each value by its 1 or 0 flag, effectively adding only the included values to the total.

Use SUMIF with Date-Based Inclusion
Calculate totals automatically based on whether a corresponding cell, such as a transaction date, is filled out.
Easily Handle Complex Data Calculations with WPS Spreadsheet
WPS Spreadsheet provides a seamless and highly compatible environment for utilizing advanced formulas like SUMIF and SUMPRODUCT. It helps you quickly calculate conditional totals with a clean, user-friendly interface.
- 1. Open your dataset in WPS: Launch WPS Office and open your workbook using the Spreadsheet module.
- 2. Input the formula: Click the cell for your total result and type =SUMPRODUCT or =SUMIF, utilizing the on-screen tooltip for guidance.
- 3. Select your ranges: Highlight your value ranges and criteria columns, then press Enter to calculate the final conditional result.

Frequently Asked Questions
Can I exclude hidden rows from a normal SUM calculation?
Yes. If you want to exclude cells simply by hiding their rows, replace the standard SUM function with SUBTOTAL. Using the formula =SUBTOTAL(109, A1:A10) will automatically exclude any rows within that range that have been manually hidden.
How do I include cells based on a specific word like 'Include'?
You can use the SUMIF function to check for exact text matches. For example, the formula =SUMIF(B1:B10, "Include", A1:A10) will sum the numbers in column A only if the corresponding cell in column B contains the exact word 'Include'.
Why does my SUMPRODUCT formula return a #VALUE! error?
A #VALUE! error in SUMPRODUCT almost always means that the ranges you selected are not identically sized. Double-check that your value range (e.g., A1:A6) and your helper column range (e.g., B1:B6) have the exact same number of rows and columns.




