Skip to main content

How to sum only filtered or visible cells in Excel?

Author: Xiaoyang Last Modified: 2024-08-29

Maybe it is easy for you to sum a column of numbers in Excel, but sometimes you need to filter or hide some data to meet your criteria. After hiding or filtering, and now you just want to add up only the filtered or visible values. If you apply the Sum function in Excel, all the values including the hidden data will be added, in this case, how could you sum only the filtered or visible cell values in Excel?


Sum only filtered or visible cell values with formula

With this SUBTOTAL function which ignores rows that have been excluded by a filter, you can easily add up only the visible cells. You can do as this:

Supposing you have a range of data, and they have been filtered as you need, see screenshot:
a screenshot of the original data range

1. In a blank cell, C13 for example, enter this formula: =Subtotal(109,C2:C12) (109 indicates when you sum the numbers, the hidden values will be ignored; C2:C12 is the range you will sum ignoring filtered rows.), and press the Enter key.
a screenshot of using the Subtotal function to sum only visible cells

Note: This formula also can help you sum only the visible cells if there are hidden rows in your worksheet. However, this formula can't sum with ignoring cells in hidden columns.

Sum/Count/Average visible cells only in a specified range with ignoring hidden or filtered cells/rows/columns

The normally SUM/Count/Average function will count all cells in the specified range on matter cells are hidden/filtered or not. While the Subtotal function can only sum/count/average with ignoring hidden rows. However, Kutools for Excel SUMVISIBLE / COUNTVISIBLE / AVERAGEVISIBLE functions will easily calculate the specified range with ignoring any hidden cells, rows, or columns.


a screenshot of using Kutools for Excel to sum, count, average visible cells only

Sum only filtered or visible cell values with User Defined Function

If you are interested in the following code, it also can help you to sum only the visible cells.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module window.

Function SumVisible(WorkRng As Range) As Double
'Update 20130907
Dim rng As Range
Dim total As Double
For Each rng In WorkRng
    If rng.Rows.Hidden = False And rng.Columns.Hidden = False Then
        total = total + rng.Value
    End If
Next
SumVisible = total
End Function

3. Save this code and enter the formula =SumVisible(C2:C12) into a blank cell. See screenshot:
a screenshot of applying the user-defined function to sum only visible cells

4. Then press Enter key and you will get the result that you want.


Sum/Count/Average only filtered or visible cells with Kutools for Excel

If you have Kutools for Excel installed, you can quickly calculate the sum/count/average only visible or filtered out cells in Excel easily.

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

For example you want to sum only visible cells only, please select the cell you will place the summing result at, type the formula =SUMVISIBLE(C3:C12) (C3:C13 is the range where you will sum only visible cells) into it, and press the Enter key.

And then the summing result is calculated with ignoring all hidden cells. See screenshot:
a screenshot of using the SUMVISIBLE function to sum only visible cells

For counting only visible cells, please apply this formula =COUNTVISIBLE(C3:C12); For averaging only visible cells, please apply this formula =AVERAGEVISIBLE(C3:C12).

Note: If you can't remember the formulas exactly, you can following below steps to sum/count/average only visible cells easily:

1. Select the cell you will place the summing result into, and click Kutools > Functions > Statistical & Math > SUMVISIBLE (or AVERAGEVISBLE, COUNTVISIBLE as you need). See screenshot:
a screenshot of enabling the SUMVISIBLE function of Kutools for Excel

2. In the opening Function Arguments dialog box, please specify the range where you will sum ignoring hidden cells, and click the OK button. See screenshot:

a screenshot of selecting the data range for calculation

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

And then the summing result is calculated with ignoring all hidden cells.


Related articles:


Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!