跳到主要內容

如何在Excel中匯總/計數已選中的複選框?

Excel 中的核取方塊是追蹤資料狀態的實用工具。想像一下,您正在使用一個包含複選框的清單 - 有些已選中,有些未選中。您可能會發現自己需要計算已選取的核取方塊的數量或計算與這些已選取的核取方塊關聯的值的總和。

在 Excel 中對選取的核取方塊進行求和或計數


在 Excel 中對選取的核取方塊進行求和或計數

在 Excel 中,沒有一個簡單的公式可以直接對選取的核取方塊進行計數或求和。為了有效解決此問題,請按照以下步驟操作:

第 1 步:將複選框連結到儲存格

  1. 開啟要對選取的複選框進行計數或求和的工作表,然後右鍵單擊複選框,然後選擇 格式控制,請參見屏幕截圖:
  2. 格式化對象 對話框中的 控制 選項卡,按一下以選擇與所選複選框相關的空白儲存格作為連結儲存格 單元鏈接 選項,不要更改任何其他選項,然後單擊 OK 按鈕。 看截圖:
  3. 然後,一個 TRUE 如果選取該複選框,則顯示在所選儲存格中;如果未選取該複選框,則顯示空白儲存格。
  4. 然後,您需要重複上述步驟,為該列的每個複選框設置一個鏈接單元格,並且最好將該單元格與同一行中相應的複選框鏈接,您將得到以下屏幕截圖:
保養竅門:如果您有多個複選框需要連結到單元格,則單獨連結它們可能會非常耗時。在這種情況下,您可以使用以下程式碼將所有複選框一次連結到儲存格。
VBA程式碼:一次將多個複選框連結到單元格
Sub LinkChecks()
'Update by Extendoffice
Dim xCB
Dim xCChar
i = 2
xCChar = "D"
For Each xCB In ActiveSheet.CheckBoxes
If xCB.Value = 1 Then
    Cells(i, xCChar).Value = True
Else
    Cells(i, xCChar).Value = False
End If
xCB.LinkedCell = Cells(i, xCChar).Address
i = i + 1
Next xCB
End Sub
備註:在上面的代碼中,I = 2, 號碼 2 是複選框的起始行,並且 xCChar =“D”,這封信 D 是您需要將復選框鏈接到的列位置。 您可以根據需要更改它們。

步驟 2:應用公式計算複選框

設定完每個複選框的連結儲存格後,您可以使用以下公式來計算複選框:

計數選中的複選框:

=COUNTIF(D2:D15,TRUE)
備註:在此公式中, D2:D15 是您為複選框設置的鏈接單元格的範圍。

根據選中的複選框對單元格值求和:

=SUMIF(D2:D15, TRUE, C2:C15)
備註:在此公式中, D2:D15 是您為複選框設置的鏈接單元格的範圍,並且 C2:C15 指的是要求和的儲存格。

將 Excel 中選取的核取方塊連結到儲存格後,對它們進行計數或求和就很簡單。透過這些步驟,您就可以善用 Excel 強大的資料管理功能。如果您有興趣探索更多 Excel 提示和技巧,我們的網站提供了數千個教程, 請點擊此處造訪它們。 感謝您的閱讀,我們期待在未來為您提供更多有用的信息!


使用 Kutools for Excel 輕鬆在所選範圍內插入多個複選框!

Excel的Kutools's 批量插入複選框 該功能允許您只需點擊幾下即可批量添加複選框。告別逐一插入複選框的繁瑣任務,並歡迎一種更有效的方式來組織資料。 立即取得即可開始 30 天免費試用!

示範:對 Excel 中選取的核取方塊進行求和或計數

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

相關文章:

  • Excel 複選框:在 Excel 中添加、選擇、刪除和使用複選框
  • 複選框是一種交互式工具,用於選擇或取消選擇一個選項,您經常會在 Web 表單或填寫調查時看到它們。 在 Excel 中,您可以通過選中或取消選中使工作表更具動態性和交互性的複選框來添加多種可能性,例如通過複選框創建清單、通過複選框插入動態圖表等。
  • 建立帶有多個複選框的下拉列表
  • 許多Excel用戶傾向於創建帶有多個複選框的下拉列表,以便每次都從列表中選擇多個項目。 實際上,您無法使用數據驗證功能創建帶有多個複選框的列表。 在本教程中,我們將向您展示兩種在Excel中創建帶有多個複選框的下拉列表的方法。

最佳辦公生產力工具

🤖 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 (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
i am trying to count the checkbox for attendance by using =sum(countif(c2: f2, true)) formula. but i am not getting correct output. all showing 0. please help
This comment was minimized by the moderator on the site
Hey :) Danke für die Hilfe! Aber muss man wirklich jedes Kästchen einzeln verknüpfen? Gibt es hierfür keine Möglichkeit der Multiplikation? Ich habe ca. 200 Kontrollkästchen in meinem Dokument und würde mir die zeit gerne sparen.
This comment was minimized by the moderator on the site
Hello, A,
To link multiple checkboxes to individual cells, the following VBA code can help you:
Sub LinkChecks()
'Update by Extendoffice
Dim xCB
Dim xCChar
i = 2
xCChar = "B"
For Each xCB In ActiveSheet.CheckBoxes
If xCB.Value = 1 Then
    Cells(i, xCChar).Value = True
Else
    Cells(i, xCChar).Value = False
End If
xCB.LinkedCell = Cells(i, xCChar).Address
i = i + 1
Next xCB
End Sub

Note: In the above code, i = 2, the number 2 is the starting row of your checkbox, and the letter B is the column location where you need link the checkboxes to. You can change them to your need.

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
I created basic spreadsheet, 7 columns with checkboxes, and 8th column with count, I need thousands rows in it over time. Right now only 50 rows, and when I change column width (of another plain text column) I need to wait for Microsoft to recalculate everything... for two minutes!!! Thank you very much Microsoft.

So, it is just basic spreadsheet; do try any sophistication, you will get burnt.
This comment was minimized by the moderator on the site
I used KUTOOLS in Excel to Batch Add Checkboxes. Now, How do I format them in a batch?
This comment was minimized by the moderator on the site
Very useful information, thank you very much.
This comment was minimized by the moderator on the site
If I counted checkboxes in a column and found some set on, how can I then clear (remove checkboxes) in that column given I have more than one column that I want to be left asis?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations