Skip to main content

How to sum visible cells only based on criteria in Excel?

Author: Xiaoyang Last Modified: 2024-01-18

In Excel, it may be easy for us to sum cells based on criteria with the SUMIFS function. However, if there is a range of filtered data, to sum the visible cells only with one or more criteria as below screenshot shown, how could you achieve this task in Excel?


Sum visible cells only based on one or more criteria with helper column

To get the total values of the visible cells only based on one or more criteria, you can create a formula helper column first, and then apply the SUMIFS function to get the total result.

For example, to get the total order of the product Hoodie in the filtered range, please do as this:

1. Enter or copy the following formula into a blank cell beside your data range, and then drag the fill handle down to fill this formula to other visible cells, see screenshot:

=AGGREGATE(9,5,D4)

2. After getting the visible values of column D, you should use the below SUMIFS function to get the total value, see screenshot:

=SUMIFS(E2:E12,A2:A12,A17)
Note: In the above formula, E2:E12 is the helper column you created in step 1 that you want to sum; A2:A12 is the criteria range, and A17 is the condition to be used on criteria range.

Tips: If you want to sum the visible cells based on more criteria, such as to get the total order of the product Hoodie which is red, please apply the below formula:
=SUMIFS(E2:E12,A2:A12,A17,C2:C12,B17)

If there are more criteria need to be added, you just need to join the criteria within the SUMIFS function like this: =SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], [criteria_range3, criteria3], ...)


Sum visible cells only based on criteria with formula

You can also create a formula based on the SUMPRODUCT, SUBTOTAL, OFFSET, ROW and MIN functions together to sum visible cells based on one or more criteria in Excel.

Please copy or enter the below formula into a blank cell to output the result, and then press Enter key to get the result, see screenshot:

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A2:A12,ROW(A2:A12)-MIN(ROW(A2:A12)),,1)),(A2:A12=A17)*(D2:D12))

Note: In the above formula, A2:A12=A17 is the criteria range and criteria that you want to use, and D2:D12 is the sum range that you want to sum.
Tips: To sum the visible cells based on multiple criteria, you just need to add the criteria like this: =SUMPRODUCT(SUBTOTAL(3,OFFSET(reference,ROW(reference)-MIN(ROW(reference)),,1)),(criteria_range1=criteria1)*(criteria_range2=criteria2)*(criteria_range3=criteria3)*(sum_range)).

  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • 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!
officetab bottom
Comments (1)
Rated 3.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
What if the one of the criteria is an empty cell? I tried using "= 0" or "" but it does not work.
Rated 3.5 out of 5
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations