How to Only Sum Visible Cells/Rows in a Filtered List in Excel

Sometimes we may want to only sum the visible cells in a filtered list or a table. We may notice that if we use SUM function directly with selecting the visible reference in the filtered list, all data in the list (also contains the hidden rows) is included into calculation.

Above all, we need to find a proper function can only sum visible cells in a filtered list and ignore the filtered-out data. Actually, excel built-in SUBTOTAL function can perform calculating like sum data, count, average for both visible & invisible cells or only visible cells properly. As we only want to show you the formula to perform sum visible cells in filter list, so in this article we will only introduce you the basic usage of SUBTOTAL function on sum data. After reading this article, I think you must have a well understanding of SUBTOTAL function, it is flexible for you to use it in your daily work.

EXAMPLE:

How to Only Sum Visible CellsRows in a Filtered List1

If we want to sum total amount for the filtered fruit, can we use SUM function here directly?

Enter =SUM(B2:B10) in B12. See screenshot below, we get 64 here, the returned value is incorrect obviously. It equals to the total amount of the whole list B2:B10, the hidden rows are also taken into calculation.

How to Only Sum Visible CellsRows in a Filtered List2

FORMULA:

Let’s apply SUBTOTAL function in this case to try to calculate total amount for ‘Apple’ again.

Step 1: Enter =SUBTOTAL(9,B2:B10).

How to Only Sum Visible CellsRows in a Filtered List3

Step 2: Press Enter to load return value.

How to Only Sum Visible CellsRows in a Filtered List4

We can see that this time correct amount 21 is displayed in B12.

HOW THIS FORMULA WORKS:

This formula only contains only one function: SUBTOTAL function.

Syntax:

=SUBTOTAL (function_num, ref1, [ref2], …)

It has several arguments like function_num, ref1, ref2. For function_num, it is a number, it shows the function used by SUBTOTAL, by providing different numbers, SUBTOTAL function can perform different calculation. As we mentioned above, SUBTOTAL function can perform most basic calculations like SUM, COUNT, AVERAGE, etc., so we need to know some useful function numbers before explaining SUBTOTAL function.

Please see below screenshots, they show the correspondence between number and function.

Function number from 1 – 101.

How to Only Sum Visible CellsRows in a Filtered List5

Function number from 101 – 111.

How to Only Sum Visible CellsRows in a Filtered List6

Refer to above function number list, we can see that SUM function has two function numbers, 9-SUM and 109-SUM. Actually, if we enter 9, SUBTOTAL function will only sum visible data and ignore the filtered-out data; and if we enter 109, SUBTOTAL function will only sum visible data and ignore the manually hidden data. See, the difference is:

9: ignore data which is hidden by filter list;

109: ignore data which is hidden manually.

In this instance, in the formula =SUBTOTAL(9,B2:B10). There are two arguments. For the first argument function_num, as data is hidden by filter list, so we enter 9 here; for the second argument, reference, we can enter the whole list B2:B10, or you can also hold your mouse and select the visible cells directly.

RESULT:

We already get proper amount for ‘Apple’, this time let’s pick Banana to check if our formula works properly after changing the filter criteria.

How to Only Sum Visible CellsRows in a Filtered List7

It works properly. SUBTOTAL function can work well on ‘sum visible cells’.

NOTES:

  1. If we change function_num from 9 to others, the SUBTOTAL function will change calculation accordingly based on the function number. For example, change 9 to 2 in this case (2 – COUNT).

How to Only Sum Visible CellsRows in a Filtered List8

We will get 2 by applying the formula.

How to Only Sum Visible CellsRows in a Filtered List9

  1. SUBTOTAL function can ignore all hidden data, so we can also use it to sum visible cells in a range. Just enter the range as the reference, the it will ignore hidden cells in this range.

Related Functions


  • Excel SUBTOTAL function
    The Excel SUBTOTAL function returns the subtotal of the numbers in a list or database. The syntax of the SUBTOTAL function is as below:= SUBTOTAL (function_num, ref1, [ref2])….
  • Excel SUM function
    The Excel SUM function will adds all numbers in a range of cells and returns the sum of these values. You can add individual values, cell references or ranges in excel.The syntax of the SUM function is as below:= SUM(number1,[number2],…)…

 

 

Related Posts

Calculate Cumulative Totals with Excel SUM Function

Today, through a simple example, we will show you how to use one of the most common-used Mathematical functions in excel, the SUM function, to add up the sum. In our daily life, we keep an account of what we ...

Check Dates in chronological order
sort dates in chronological order1

Assume you have a date list that has different date formats, as seen in the accompanying picture. In this instance, Excel's Sort function will fail to sort them appropriately. However, you may convert all various date formats to a particular ...

How to Use 3D SUM Multiple Worksheets
3D sum multiple worksheets1

To sum a range of numbers is straightforward for most Excel users, but do you know how to establish a 3D reference to total the same range of numerous sheets. In this post, I will present the steps for this ...

If Cell Begins with One of Three Supplied Characters
If Cell Begins with One of Three Supplied Characters

If you want to test values to see if they begin with some given specific characters like “x”, ”y”, or “z”, you can create a formula with COUNTIF and SUM functions to return results. EXAMPLE You can see “TRUE” or ...

Average per Week by Formula in Excel
Average per Week 1

We usually apply AVERAGE function or relevant functions to return average directly in Excel worksheet. But in some situations, only applying average relevant functions cannot figure out our problem. Sometimes we can create a formula with functions and mathematical operation ...

How to Sum if Contains an Asterisk
How to Sum if Contains an Asterisk 7

To add numbers together we need to apply SUM function. And if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. If ...

How to Sum in Vertical Range
How to Sum in Vertical Range 8

If we want to add numbers based on some conditions in Excel worksheet, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. In this article, we will introduce you the method ...

How to Sum in Horizontal Range
How to Sum in Horizontal Range9

To add numbers together we need to apply SUM function. But if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. In ...

How to Sum with Criteria and Or Logic in Excel
How to Sum with Criteria and Or Logic in Excel 8

To add numbers together we need to apply SUM function. And if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. If ...

How To Sum the Largest N Values in Excel

Sometimes we may want to sum the largest N numbers or top N numbers in a range. In this article, we will show you the method of “SUM the Largest N Numbers” by a simple formula which consist of SUMPRODUCT ...

Sidebar