跳到主要內容

如何在Excel中僅匯總經過過濾或可見的單元格?

在Excel中對一列數字求和也許很容易,但是有時您需要過濾或隱藏一些數據以滿足您的條件。 隱藏或過濾後,現在您只想只累加過濾或可見值。 如果在Excel中應用Sum函數,則將添加所有值(包括隱藏數據),在這種情況下,如何只對Excel中經過過濾或可見的單元格值求和?


用公式對僅過濾或可見單元格值求和

有了這個 小計 該函數會忽略已被過濾器排除的行,因此您可以輕鬆地僅添加可見單元格。 您可以這樣做:

假設您具有一系列數據,並且已根據需要對其進行了過濾,請參見屏幕截圖:

1。 在空白單元格(例如C13)中,輸入以下公式: =小計(109,C2:C12) (109 表示在對數字求和時,隱藏的值將被忽略; C2:C12 是您將忽略忽略的行而求和的範圍。),然後按 Enter 鍵。

注意: 如果工作表中有隱藏的行,此公式還可以幫助您僅匯總可見的單元格。 但是,此公式不能等於忽略隱藏列中的單元格。

僅在指定範圍內對可見單元格進行求和/計數/平均,而忽略隱藏或過濾的單元格/行/列

通常,SUM / Count / Average函數將對是否隱藏/過濾的物質像元計數指定範圍內的所有像元。 小計功能只能忽略隱藏的行來求和/計數/求平均值。 但是,Kutools for Excel 可見的 / 清晰可見 / 平均可見度 函數將忽略任何隱藏的單元格,行或列,輕鬆地計算指定範圍。


廣告總數僅計算平均可見單元格

使用用戶定義函數僅對過濾後或可見的單元格值求和

如果您對以下代碼感興趣,它也可以幫助您僅匯總可見單元格。

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。 然後按 Enter 鍵,您將得到想要的結果。


使用Kutools for Excel僅對已過濾或可見的單元格求和/計數/平均

如果您安裝了Kutools for Excel,則可以快速輕鬆地計算Excel中僅可見或過濾出的單元格的總和/計數/平均值。

Excel的Kutools - 使用 300 多種基本工具增強 Excel 功能。 享受全功能 30 天免費試用,無需信用卡! 立即行動吧!

例如,您只想對可見的單元格求和,請選擇將求和結果放在其中的單元格,鍵入公式 = SUMVISIBLE(C3:C12) (C3:C13是您僅對可見單元格求和的範圍),然後按 Enter 鍵。

然後,在忽略所有隱藏單元的情況下計算求和結果。 看截圖:

僅計算可見細胞,請應用此公式 = COUNTVISIBLE(C3:C12); 對於僅可見單元的平均,請應用此公式 =平均可見度(C3:C12).

注意: 如果您不記得確切的公式,可以按照以下步驟輕鬆地對可見單元格進行求和/計數/平均:

1.選擇要放入求和結果的單元格,然後單擊 庫工具 > 操作功能 > 統計與數學 > 可見的 平均可見, 清晰可見 根據需要)。 看截圖:

2.在打開的“函數參數”對話框中,請指定匯總忽略的單元格的範圍,然後單擊 OK 按鈕。 看截圖:

Excel的Kutools - 使用 300 多種基本工具增強 Excel 功能。 享受全功能 30 天免費試用,無需信用卡! 立即行動吧!

然後,在忽略所有隱藏單元的情況下計算求和結果。


演示:僅對過濾後或可見的單元格求和/計數/平均


Excel的Kutools:超過 300 個方便的工具觸手可及! 立即開始 30 天免費試用,沒有任何功能限制。 現在就下載!

通過在Excel中刪除隱藏的行,輕鬆匯總/計數僅過濾/可見的單元格

當在Excel中對過濾出的單元格進行匯總/計數時,SUM函數或Count函數將不會忽略隱藏的單元格。 如果隱藏/過濾的行被刪除,我們只能輕鬆地對可見單元格進行求和或計數。 您可以嘗試Kutools for Excel的 刪除隱藏(可見)行和列 實用程序來解決它。


廣告刪除隱藏行第3列

相關文章:

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為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