How to sum only filtered or visible cells in Excel? (2024)

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
  • Sum only filtered or visible cell values with User Defined Function
  • Sum/Count/Average only filtered or visible cells with Kutools for 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:
How to sum only filtered or visible cells in Excel? (1)

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.
How to sum only filtered or visible cells in Excel? (2)

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.

Get a 30-day full-featured free trial now!


How to sum only filtered or visible cells in Excel? (3)

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 20130907Dim rng As RangeDim total As DoubleFor Each rng In WorkRng If rng.Rows.Hidden = False And rng.Columns.Hidden = False Then total = total + rng.Value End IfNextSumVisible = totalEnd Function

3. Save this code and enter the formula =SumVisible(C2:C12) into a blank cell. See screenshot:
How to sum only filtered or visible cells in Excel? (4)

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 a full-featured 30-day FREE trial with no credit card required! 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:
How to sum only filtered or visible cells in Excel? (5)

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:
How to sum only filtered or visible cells in Excel? (6)

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:

How to sum only filtered or visible cells in Excel? (7)

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy a full-featured 30-day FREE trial with no credit card required! Get It Now

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

Demo: Sum/Count/Average only filtered or visible cells


Kutools for Excel: Over 300 handy tools at your fingertips! Start your 30-day free trial with no feature limitations today. Download Now!

Easily sum/count only filtered out/visible cells by deleting hidden rows in Excel

When summing/counting filtered out cells in Excel, the SUM function or Count function will not ignore hidden cells. If hidden/filtered rows are removed, we can only sum or count visible cells easily. You can try Kutools for Excel's utility to solve it.

Get a 30-day full-featured free trial now!


How to sum only filtered or visible cells in Excel? (8)

Related articles:

How to sum the absolute values in Excel?

How to quickly sum every other or nth row/column in Excel?

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 | ...
Featured Features: Grid Focus |Design View | Big Formula Bar ||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 Toolsets: 12 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, ...) | (Advanced Combine Rows, Split Cells, ...) | ... and more

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...

How to sum only filtered or visible cells in Excel? (9)

Read More... Free Download...

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!

Read More... Free Download...

Sort comments by

Oldest First

Newest First

Comments (26)

No ratings yet. Be the first to rate!

Loux

#42664

This comment was minimized by the moderator on the site

Bonjour,
Moi j'ai un problème comparable mais différent, en gros quand je filtre mes colonnes et que je veux copier la même valeur dans mes lignes visibles, toute les lignes qui sont entre mes lignes visibles sont elles aussi modifiées.
Comment faire pour que seule mes lignes visibles soient modifiés.

Reply

skyyang Loux

#42935

This comment was minimized by the moderator on the site

Hello, Loux

Do you mean to copy and paste cell vaues to visible cells only? If so, maybe the below articles can help you:
https://www.extendoffice.com/documents/excel/2331-excel-paste-data-into-filtered-list.html
https://www.extendoffice.com/documents/excel/2617-excel-paste-to-visible-filtered-cells.html

Please try it, thank you!

Reply

Report

Cristobal Alejandro

#41286

This comment was minimized by the moderator on the site

Hola,

No me resulta sumar el rango de una fila considerando sólo las columnas visibles.

Alguna formula o alguna macro?

Gracias!!!

Reply

skyyang Cristobal Alejandro

#41520

This comment was minimized by the moderator on the site

Hello, Cristobal,
Sorry, I can't understand your problem clearly, could you explain your problem in English?
Or you can insert a screenshot or a file to describe your problem.
Thank you!

Reply

Report

Cristobal Alejandro

#41285

This comment was minimized by the moderator on the site

Hola,

Quiero sumar dentro de un rango de fila que al ocultar columnas sume sólo las visibles.
No he logrado hacerlo, alguna fórmula? o tendría que hacerse con una marcro?

Muchas gracias!!!

Reply

#22360

This comment was minimized by the moderator on the site

how to skip hidden cells from excel formulae in filtered sheet....

yellow coloured cells are involving hidden cells due to filter....

Reply

Report

#22361

This comment was minimized by the moderator on the site

Hi,
What kinds of calculation do you need to do? Kutools for Excel supports three functions to count/sum/average ignoring all hidden cells.

Reply

Report

#22366

This comment was minimized by the moderator on the site

or like this

column a column d

100 10

90 10

80 10

where 90=100-10, 80=90-10, and so on.........

dragging the formula includes hidden cells in formula

Reply

Report

#22365

This comment was minimized by the moderator on the site

When i am applying say G3-K2 Formula in filtered excel sheet & dragging the formula, it includes hidden cells

for example

Validity Lifting Qty
27054.59 123.41
26931.18 330.98
26600.20 493.66
26106.54 476.38
25630.16 480.64
25149.52 577.06

now value in validity comes after get subtracted by lifted qty (like 2nd value 26931.18=27054.59-123.41)

3rd value in validity=2nd value in validity-2nd value in lifted qty. and so on.....

now this sheet is filtered & when i drag the formulae in validity column, it includes hidden cells, due to filter.

which gives me wrong result

Reply

Report

half yodha

#22364

This comment was minimized by the moderator on the site

Validity Lifting Qty
27054.59 123.41
26931.18 330.98
26600.20 (26600.2=26931.18-330.98) 493.66
26106.54 476.38
25630.16 480.64
25149.52 577.06

Reply

half yodha

#22362

This comment was minimized by the moderator on the site

When i am applying say G3-K2 Formula in filtered excel sheet & dragging the formula, it includes hidden cells

for example

Validity Lifting Qty
27054.59 123.41
26931.18 330.98
26600.20 493.66
26106.54 476.38
25630.16 480.64
25149.52 577.06

now value in validity comes after get subtracted by lifted qty (like 2nd value 26931.18=27054.59-123.41)

3rd value in validity=2nd value in validity-2nd value in lifted qty. and so on.....

now this sheet is filtered & when i drag the formulae in validity column, it includes hidden cells, due to filter.

which gives me wrong result

Reply

half yodha

#22363

This comment was minimized by the moderator on the site

Hi,
The normal =G3-K2 will not ignore any hidden cells/rows/column by dragging to copy. I am sorry I can not figure out a proper formula for your. All formulas or methods talked in this article is just about sum/count/average ignoring hidden cells.

Reply

Report

half yodha

#22359

This comment was minimized by the moderator on the site

how i can skip hidden cells from excel formulae in filtered sheet

Reply

Sab6247

#16773

This comment was minimized by the moderator on the site

Im trying to use the AVERAGEVISIBLE function to average the 12 largest values in a column, this works in the normal AVERAGE function as=AVERAGE(LARGE(E971:E1540,{1,2,3,4,5,6,7,8,9,10,11,12})) however when i try to use the average visible function it returns #VALUE!, any ideas?

Reply

JPas

#15127

This comment was minimized by the moderator on the site

This is awesome! Thanks so much.

Reply

DataCruncher

#14747

This comment was minimized by the moderator on the site

Sorry I messed up the posts security code at bottom and seems like my question may have been deleted as it asked me to try another one.I can get the VBA code for SUMVISIBLE to work well if my data is vertical and I hide rows. However it doesn't if my data runs horizontal and I want to hide columns. Is there a way to program this? Thanks!

Reply

DataCrucher

#14746

This comment was minimized by the moderator on the site

I am able to get your VBA for =SUMVISIBLE above to work good.However just if my data runs vertically and I am hiding rows.Is there a way to program it so you can have your data run horizontally and it still work when you hide columns? THANKS!

Reply

ExcelNewbie

#14037

This comment was minimized by the moderator on the site

The solution worked for me. :D

Reply

There are no comments posted here yet

Load More

Please leave your comments in English

Posting as Guest

How to sum only filtered or visible cells in Excel? (2024)

FAQs

How to sum only filtered or visible cells in Excel? ›

Sum Only Visible Cells in Excel

How to sum only filtered visible cells in Excel? ›

Just organize your data in table (Ctrl + T) or filter the data the way you want by clicking the Filter button. After that, select the cell immediately below the column you want to total, and click the AutoSum button on the ribbon. A SUBTOTAL formula will be inserted, summing only the visible cells in the column.

How to count only filtered visible cells in Excel? ›

For example, if you have a range of cells that contains numbers, text, and logical values, and you want to count only the visible cells that contain any value, you can use the formula =SUBTOTAL(109,A2:A10) .

How do you sum only certain cells in Excel? ›

If you want, you can apply the criteria to one range and sum the corresponding values in a different range. For example, the formula =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John."

How do you count non blank filtered cells in Excel? ›

Use the COUNTA function to count only cells in a range that contain values. When you count cells, sometimes you want to ignore any blank cells because only cells with values are meaningful to you. For example, you want to count the total number of salespeople who made a sale (column D).

How do you exclude hidden cells in Excel count? ›

The SUBTOTAL syntax goes like this: SUBTOTAL(function_num,ref1,[ref2],...) To include hidden values in your range, you should set the function_num argument to 2. To exclude hidden values in your range, set the function_num argument to 102.

How do you select only visible cells for formula in Excel? ›

Click Home > Find & Select, and pick Go To Special. Click Visible cells only > OK.

How to average only filtered visible cells in Excel? ›

To average filtered rows in Excel, first filter out the desired data set, then select all the cells in the row range you wish to average, and press the Average function in the Home tab.

How do I sum visible rows only with criteria in Excel? ›

Use the SUBTOTAL function in Excel to sum values in visible rows only. It is designed specifically for columns of data and will ignore rows hidden by a filter. Additionally, SUBTOTAL can be set to exclude manually hidden rows.

How do you sum only marked cells in Excel? ›

Select one or more ranges where you want to count and sum colored cells. Make sure the selected range(s) contains numerical data. Press Alt + F8, select the SumCountByConditionalFormat macro in the list, and click Run.

What is the difference between Sumif and Sumifs? ›

The only difference between Excel SUMIFS & SUMIF functions is that SUMIFs can check for multiple criteria at once, while SUMIF can check for one criterion at a time. The SUMIF formula returns the sum of cells based on one criterion (a result that matches one condition).

How do I select only visible cells in Excel after filtering? ›

Click Home > Find & Select, and pick Go To Special. Click Visible cells only > OK.

Top Articles
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 5841

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.