跳到主要内容

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

在Excel中对一列数字求和也许很容易,但是有时您需要过滤或隐藏一些数据以满足您的条件。 隐藏或过滤后,现在您只想只累加过滤或可见值。 如果在Excel中应用求和函数,将添加所有值(包括隐藏数据),在这种情况下,如何只对Excel中经过过滤或可见的单元格值求和?


用公式仅对过滤后或可见的单元格值求和

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

假设您有一系列数据,并且已根据需要对其进行了过滤,请参见屏幕截图:

1。 在空白单元格(例如C13)中,输入以下公式: =小计(109,C2:C12) (109 表示在对数字求和时,隐藏的值将被忽略; C2:C12 是您将忽略过滤行而求和的范围。),然后按 输入 键。

请注意: 如果工作表中有隐藏的行,此公式还可以帮助您仅汇总可见的单元格。 但是,此公式不能等于忽略隐藏列中的单元格。

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

通常,SUM/Count/Average 函数将对指定范围内的所有单元格进行计数,该单元格是否隐藏/过滤。而小计函数只能求和/计数/平均,忽略隐藏行。然而,Kutools for Excel 可见的 / 清晰可见 / 平均可见度 函数将忽略任何隐藏的单元格,行或列,轻松地计算指定范围。


广告总数仅计算平均可见单元格

使用用户定义的功能仅对过滤后或可见的单元格值求和

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

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

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中仅可见或过滤掉的单元格的总和/计数/平均值。

Kutools for Excel - 使用 300 多种基本工具增强 Excel 功能。 享受全功能 30 天免费试用,无需信用卡! 立即行动吧!

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

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

仅计算可见细胞,请应用此公式 = COUNTVISIBLE(C3:C12); 对于仅可见单元的平均,请应用此公式 =平均可见度(C3:C12).

请注意: 如果您不记得确切的公式,可以按照以下步骤轻松地对可见单元格进行求和/计数/平均:

1.选择要放入求和结果的单元格,然后单击 库工具 > 主要工作内容 > 统计与数学 > 可见的 (或 平均可见, 清晰可见 根据需要)。 看截图:

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

Kutools for Excel - 使用 300 多种基本工具增强 Excel 功能。 享受全功能 30 天免费试用,无需信用卡! 立即行动吧!

然后,在忽略所有隐藏单元的情况下计算求和结果。


演示:仅对过滤后的或可见的单元格求和/计数/平均


Kutools for Excel:超过 300 个方便的工具触手可及! 立即开始 30 天免费试用,没有任何功能限制。 立即下载!

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

当对 Excel 中筛选出的单元格进行求和/计数时,SUM 函数或 Count 函数不会忽略隐藏单元格。如果隐藏/过滤的行被删除,我们只能轻松地对可见单元格进行求和或计数。你可以尝试 Kutools for Excel's 删除隐藏(可见)行和列 实用程序来解决它。


广告删除隐藏行第3列

相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (26)
No ratings yet. Be the first to rate!
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.
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!
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!!!
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!
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!!!
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....
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.
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
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
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
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
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.
This comment was minimized by the moderator on the site
how i can skip hidden cells from excel formulae in filtered sheet
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?
This comment was minimized by the moderator on the site
This is awesome! Thanks so much.
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!
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!
This comment was minimized by the moderator on the site
The solution worked for me. :D
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations