跳到主要內容

如何在Excel中對數字中的所有數字求和?

如果您現在有一個包含值的單元格,則要將該單元格的所有數字加在一起。 例如,如果您在一個單元格中具有值12345,則需要執行以下計算:1 + 2 + 3 + 4 + 5,並獲得值15。是否有什麼好方法可讓您對一個數字的所有數字求和在Excel中?


用公式將一個單元格中數字的所有數字相加

無需手動逐個添加數字,以下公式可以幫助您快速獲取單元格的總和。

1.請輸入以下任一公式或將其複製到空白單元格中以輸出結果:

=SUMPRODUCT(1*MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))
=SUM(INDEX(1*(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)),,))

2。 然後按 Enter 鍵返回結果,並選擇單元格C2,然後將填充手柄拖到您要應用此公式的範圍內,您將獲得每個單元格數字的總和。

筆記:

  • 在上述公式中, A2 是包含您要對其數字求和的數字的單元格。
  • 如果數字中帶有負號或小數點,則公式將返回#VALUE! 錯誤。

使用用戶定義的功能將一個單元格中數字的所有數字相加

要累加一個單元號的所有數字,以下VBA代碼也可以為您提供幫助。

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:匯總一個單元格編號的所有數字

 Function SumDigits(Number As String) As Integer
'Updateby Extendoffice
Dim x As Integer, C As String
For x = 1 To Len(Number)
C = Mid(Number, x, 1)
If IsNumeric(C) Then SumDigits = SumDigits + C
Next
End Function

3。 然後保存並關閉此代碼,返回到工作表,然後輸入此公式 = SumDigits(A2) 到一個空白單元格中,然後將填充手柄向下拖動到要包含此公式的單元格中,您將得到以下結果:


通過簡單的功能將一個單元格中數字的所有數字相加

在這裡,我還可以談論一個有用的工具- Excel的Kutools,其 單元格中的總和 功能,您可以快速將一個數字中的所有數字相加。

注意:要應用此 單元格中的總和,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用該功能。

安裝後 Excel的Kutools,請這樣做:

1。 單擊要在其中輸出結果的空白單元格。

2。 然後點擊 庫工具 > 公式助手 > 公式助手,請參見屏幕截圖:

3。 在 公式助手 對話框中,進行以下操作:

  • 選擇 數學 選項從 公式 類別 下拉列表;
  • 然後選擇 單元格中的總和 來自 選擇一個草 列錶框;
  • 在右邊 參數輸入 部分中,選擇要對數字求和的單元格。

4。 然後點擊 Ok 按鈕,並將填充手柄拖到要對單元格中的數字求和的單元格上。 每個單元格中的所有數字都已添加在一起,請參見屏幕截圖:

立即下載和免費試用Excel的Kutools!


更多相關文章:

  • Excel中範圍的總和對角線
  • 在進行某些算術計算時,可能需要對一個表中的對角線數字求和。 實際上,您也可以在Excel中對角線數字求和,這不需要您將數字一一求和。 如果您想進一步了解此問題,請閱讀以下文章。
  • 合併重複的行並求和
  • 在Excel中,當您具有一系列包含某些重複項的數據時,您可能總是會遇到此問題,現在您想要合併重複數據並在另一列中將相應的值求和,如下面的屏幕截圖所示。 您如何解決這個問題?
  • 基於列和行標準的求和
  • 我有一系列包含行標題和列標題的數據,現在,我想對滿足列標題和行標題條件的單元格求和。 例如,要匯總列條件為Tom且行條件為Feb的單元格,如下面的屏幕快照所示。 本文,我將討論一些有用的公式來解決它。
  • 在Excel中將數字從1到N求和
  • 對於大多數Excel用戶,有時,您需要從文本字符串的開頭刪除前n個字符,或者從文本字符串的結尾刪除最後x個字符,如下面的屏幕快照所示。 本文,我將介紹一些方便的技巧,以在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 (26)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bonjour,
Je cherchais justement cette solution c.à.d. comment faire la somme des chiffres d'un nombre (de 4 chiffres) sur excel et je suis tombé sur ce site. Je suis en profonde admiration devant l'intelligence de certains qui ont trouvé des formules de ouf. Malheureusement, je ne suis pas à ce niveau pour les mettre en pratique. Je me suis dit (car j'aime me parler, comme ça, j'ai toujours raison LOL) que pourquoi chercher compliqué quand on peut faire plus simple et j'ai trouvé une solution qui n'est pas élégante (OK je ne suis pas Einstein) et qui marche. Que veut on de plus ! Je vous la donne ici.
Je prends un exemple avec un nombre à 4 chiffres mais vous pouvez ajouter autant de chiffres que vous voulez. Disons que ce nombre est dans la cellule A2 pour l'exemple :
=STXT($A$2;1;1)+STXT($A$2;2;1)+STXT($A$2;3;1)+STXT($A$2;4;1)
J'ai mis des $ pour pouvoir copier plus facilement et ensuite je n'ai qu'à changer le rang du chiffre, dans mon cas 1, 2, 3, 4 et vous pouvez allez aussi loin que vous voulez
En anglais, vous remplacez STXT par MID et en allemand par TEIL
Si vous voulez la somme du résultat (dans la cellule A3 par ex.), vous faites la même chose en remplaçant A2 par A3.
Voila
Julien
This comment was minimized by the moderator on the site
Já procurei mais não acho por nada eu queira fazer uma planilha que o resultado da soma final reduz o número a 1 dígito. Por exemplo o resultado deu 7+6=13 e ele virasse 1+3= 4
This comment was minimized by the moderator on the site
I want to two digits like: 11.03 and 1.11, so i want to answer is coming 13.02.kindly provide a formula.
This comment was minimized by the moderator on the site
I play KillerSudoku: If I have n number of sums (not the total or answer) but I have say 2 or 3 or more empty cells with number possibilities who's sum totals 15; say, the total is 15 and I have 4 empty squares that all live in the same cage (meaning non-repeating), how do I show all possible sums: ie, 2+3+6+4, or 3+5+1+6, or 3+4+6+1 and so on. Also, I need to sometimes show all possible sums with repeating. Can this be done in Excel
This comment was minimized by the moderator on the site
Hello, Kevin,Maybe the following article can do you a favor:https://www.extendoffice.com/documents/excel/3557-excel-find-all-combinations-that-equal-given-sum.html
Please try, thank you!
This comment was minimized by the moderator on the site
Hello Experts. I have a question. For instance i have 18487.73486. I want a cell to sum 18487 and another cell that would sum the 73486. How do I go about doing it? Will appreciate any response. tia
This comment was minimized by the moderator on the site
Your Solution or the Formula is excellent. Thanks for the quick fix .
This comment was minimized by the moderator on the site
I typed 3 zero in 2nd column and put sum formula i.e. 50 in 1st column and three zero in 2nd column but excel is not working because the zero are going to remove automatically. Could you please help me.
This comment was minimized by the moderator on the site
Hello, Murtuza,
Sorry, I don't get your point, please give more detailed information about your problem, or you can insert a screenshot here.
Thank you!
This comment was minimized by the moderator on the site
How to count number in a cell in excel i.e. for example : 1+1+2+3+4+5+6+7 = 8
This comment was minimized by the moderator on the site
Hi,
Maybe the below article can solve your problem, please check it:
https://www.extendoffice.com/documents/excel/1504-excel-count-letters-in-cell.html
Hope it can help you!
This comment was minimized by the moderator on the site
Thank you so much
This comment was minimized by the moderator on the site
I am trying to find the avg of multipule numbers in a cell, lets say 22,11,18,14,3,6 are all in the same cell is there a way for another cell to display 12.3?
This comment was minimized by the moderator on the site
Hello, john,
To calculate the average of multiple numbers within a cell, please apply the below formula:
=IF(A1="","",ROUND(SUMPRODUCT(--(0&TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",99)),ROW($1:$99)*99-98,99))))/(LEN(A1)-LEN(SUBSTITUTE(A1,",",))+1),2))
Note: the last number 2 in the formula indicates that retain two decimal places after rounding. You can change it to your need.

Please try it, hope it can help you!
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