提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何仅汇总Excel中的过滤或可见单元格?

您可能很容易在Excel中总结一列数字,但有时您需要过滤或隐藏一些数据以符合您的标准。 隐藏或过滤后,现在只需要合计已过滤或可见的值。 如果您在Excel中应用Sum函数,则会添加包括隐藏数据在内的所有值,在这种情况下,如何才能在Excel中求和已过滤或可见的单元格值?

用公式只计算已过滤或可见的单元格值

用户定义函数只求过滤或可见单元格值

总和/计数/平均值只使用Kutools for Excel过滤或可见的单元格

总计/计数/平均可见单元格仅在指定范围内,忽略隐藏或过滤的单元格/行/列

正常的SUM / Count / Average函数会计算指定范围内所有单元格被隐藏/过滤或不被隐藏的细胞。 而小计函数只能通过忽略隐藏行来求和/计算/平均。 但是,Excel的Kutools SUMVISIBLE / COUNTVISIBLE / AVERAGEVISIBLE 函数将轻松计算指定的范围,忽略任何隐藏的单元格,行或列。 全功能免费试用60天!
广告总数只计算平均可见的单元格

Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel - 最佳办公生产力工具将解决您的大部分Excel问题
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 适用于Office 2007-2019和365; 支持所有语言; 在公司轻松部署; 全功能60天免费试用。

箭头蓝色右泡 用公式只计算已过滤或可见的单元格值

有了这个 小计 函数会忽略已被过滤器排除的行,您可以轻松地仅添加可见单元格。 你可以这样做:

假设您有一系列数据,并且已根据需要进行过滤,请参阅截图:

1。 在一个空白单元格中,例如C13输入这个公式: =小计(109,C2:C12) (109 表示当你总结数字时,隐藏的值将被忽略; C2:C12 是您将忽略过滤行的总和。),然后按 输入 键。

请注意: 如果工作表中存在隐藏行,此公式也可以帮助您仅汇总可见单元格。 但是,这个公式不能与忽略隐藏列中的单元格。


箭头蓝色右泡 用户定义函数只求过滤或可见单元格值

如果您对以下代码感兴趣,它也可以帮助您仅汇总可见单元格。

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块,并将以下代码粘贴到“模块”窗口中。

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。 保存此代码并输入公式 = SumVisible(C2:C12) 进入空白单元格。 看截图:

4。 然后按 输入 键,你会得到你想要的结果。


箭头蓝色右泡 总和/计数/平均值只使用Kutools for Excel过滤或可见的单元格

如果您安装了Kutools for Excel,您可以快速计算Excel中总和/计数/平均值,只需在Excel中可视化或过滤掉单元格。

例如,您只想求和可见单元格,请选择您要将求和结果放在的单元格,然后键入公式 = SUMVISIBLE(C3:C12) (C3:C13是你只能将可见单元求和的范围)加入其中,然后按下 输入 键。

然后计算求和结果,忽略所有隐藏的单元格。 看截图:

仅计算可见单元格,请应用此公式 = COUNTVISIBLE(C3:C12); 为了仅平均可见单元格,请应用此公式 = AVERAGEVISIBLE(C3:C12).

请注意: 如果您完全不记得公式,则可以按照以下步骤轻松地对可见单元求和/计算/平均:

1。 选择您要将求和结果放入的单元格,然后单击 Kutools > 功能 > 统计与数学 > SUMVISIBLE (或 AVERAGEVISBLE, COUNTVISIBLE 如你所需)。 看截图:

2。 在打开的函数参数对话框中,请指定总计忽略隐藏单元格的范围,然后单击 OK 按钮。 看截图:

Kutools for Excel - 包括多个用于Excel的300便捷工具。 全功能免费试用60天,无需信用卡! 现在加入

然后计算求和结果,忽略所有隐藏的单元格。


在这个视频中, Kutools Kutools Plus 选项卡添加 Kutools for Excel。 如果需要,请点击 60天免费试用,不受限制!

通过删除Excel中的隐藏行,轻松地仅对已过滤/可见单元格进行求和/计数

在Excel中求和/计数过滤出的单元格时,SUM函数或Count函数不会忽略隐藏的单元格。 如果隐藏/过滤行被删除,我们只能简单地求和或计数可见单元格。 您可以尝试Kutools for Excel's 删除隐藏(可见)行和列 实用程序来解决它。 全功能免费试用60天!
广告删除隐藏行列3

箭头蓝色右泡相关文章:

如何在Excel中求和绝对值?

如何快速汇总Excel中的每一行或第n列?


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    half yodha · 1 years ago
    how to skip hidden cells from excel formulae in filtered sheet....

    yellow coloured cells are involving hidden cells due to filter....
    • To post as a guest, your comment is unpublished.
      Tang Kelly · 1 years ago
      Hi,
      What kinds of calculation do you need to do? Kutools for Excel supports three functions to count/sum/average ignoring all hidden cells.
      • To post as a guest, your comment is unpublished.
        half yodha · 1 years ago
        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
      • To post as a guest, your comment is unpublished.
        half yodha · 1 years ago
        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
      • To post as a guest, your comment is unpublished.
        half yodha · 1 years ago
        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
      • To post as a guest, your comment is unpublished.
        half yodha · 1 years ago
        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
        • To post as a guest, your comment is unpublished.
          Tang Kelly · 1 years ago
          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.
  • To post as a guest, your comment is unpublished.
    half yodha · 1 years ago
    how i can skip hidden cells from excel formulae in filtered sheet
  • To post as a guest, your comment is unpublished.
    Sab6247 · 3 years ago
    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?
  • To post as a guest, your comment is unpublished.
    JPas · 3 years ago
    This is awesome! Thanks so much.
  • To post as a guest, your comment is unpublished.
    DataCruncher · 4 years ago
    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!
  • To post as a guest, your comment is unpublished.
    DataCrucher · 4 years ago
    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!
  • To post as a guest, your comment is unpublished.
    ExcelNewbie · 4 years ago
    The solution worked for me. :D
  • To post as a guest, your comment is unpublished.
    MJK · 4 years ago
    Thanks a lot!! It was very helpful:)
  • To post as a guest, your comment is unpublished.
    Steve Ostroff · 4 years ago
    I had a similar issue where I wanted to calculate differences from two cells in different rows where I use a Data Filter to discriminate which rows are displayed. I solved the problem in the following method:

    1. Create a new column [or Row depending on what is hidden] and label it Visible.
    2. Create a new column that will be used to maintain the value from the last "visible" row that you want to bring down.
    3. In the "Visible" column, use the formula: =+SUBTOTAL(102,cell_in_row_or_column)
    This will have a 1 as soon as you type it, but will be 0 if the cell is not visible.
    4. In the column created for step 2, you need a simple formula: +IF(A,B,C); where A=cell returning Visible status, B the value you want to operate on from the same row [just a copy], C the value from the same cell in the row previous since the cell is not visible.

    In this way, the last "Visible" item is propagated behind the scenes to the row above the visible row(s). This allows you to create simple formulas performing the operations on the preceding row. This works for many situations where you need to deal with individual data points, as opposed to ranges which are better with Subtotal.
  • To post as a guest, your comment is unpublished.
    Pretti · 5 years ago
    hi when i sue this function, and filter, the totals dont display. why?
  • To post as a guest, your comment is unpublished.
    Roy Rouessart · 5 years ago
    When you unhide rows then "=SumVisible()" reflects error.
    Is it possible to change "Function" to reflect either "Zero" or "No hidden Rows"?
    • To post as a guest, your comment is unpublished.
      Roy Rouessart · 5 years ago
      Thanks Milinda - I have inserted the module in both "Book 1" and "Personal.xlsb" but when I open a new file I don't seem able to access the function. Please what have I done wrong?
  • To post as a guest, your comment is unpublished.
    alex17111 · 5 years ago
    How do i add criteria to the 2nd option.
    Eg.if i have a range of values i want it to select values which have criteria of "X" in a column.
  • To post as a guest, your comment is unpublished.
    Paul_007 · 5 years ago
    Hi All,

    I would like to add two values in different collumns, but only with visible cells when I use a filter.
    eg. B3=B2+A3
    I have tried to use the SUBTOTAL function, but that does not work.
    Please advise, thanks in advance!
    regards,
    • To post as a guest, your comment is unpublished.
      Milind Ranka · 5 years ago
      Create a row on top of the row you will choose to apply filter.
      In the column for which you need total write the formula
      =subtotal(9,{start column no.},{end column no})

      For example
      if for column A i need the subtotals based on value in column b
      then if the header row for data is in row 2 and row 1 is blank
      then put the formula in column A1 as =subtotal(9,A2:a999)

      As you change the filter condition on column B you will see total changing.