跳到主要内容

如何在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。 然后按 输入 键以返回结果,并选择单元格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) 到一个空白单元格中,然后将填充手柄向下拖动到要包含此公式的单元格中,将得到以下结果:


通过简单的功能将一个单元格中数字的所有数字相加

在这里,我还可以讨论一个有用的工具- Kutools for Excel,其 单元格中的总和 功能,您可以快速将一个数字中的所有数字相加。

请注意:申请这个 单元格中的总和,首先,您应该下载 Kutools for Excel,然后快速轻松地应用该功能。

安装后 Kutools for Excel,请这样做:

1。 单击要在其中输出结果的空白单元格。

2。 然后点击 库工具 > 公式助手 > 公式助手,请参见屏幕截图:

3。 在 公式助手 对话框中,进行以下操作:

  • 选择 数学 选项从 公式 Type 下拉列表;
  • 然后选择 单元格中的总和 来自 选择一个草 列表框;
  • 在右边 参数输入 部分中,选择要对数字求和的单元格。

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 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,
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