提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何在Excel中对文本和数字的单元格进行求和?

例如,我有一个包含数字和文本字符串的值列表,现在,我只想总结基于相同文本的数字,请看下面的截图。 通常情况下,你不能直接在文本列表中总结列表中的值,在这里,我将介绍一些公式来处理这个任务。


将文本字符串拆分成单独的文本和数字列:

Kutools for Excel拆分单元格 功能是一个强大的工具,它可以帮助您将单元格值拆分成多个列或行,它可以帮助您将字母数字字符串分割成单独的文本和数字列等。

doc总和文本号8

Kutools for Excel:比200方便的Excel加载项,可以在60天免费试用。 下载并免费试用现在!


包含文本和数字的单元格基于特定的文本和公式


Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel解决了您的大多数问题,并使您的生产率提高了80%
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 与Office 2007-2019和365一起使用; 支持所有语言; 在您的企业或组织中轻松部署。

您可以使用数组公式来根据单元格中相应的文本字符串对数字进行求和,具体操作如下:

1. 首先,你可以写下你想在列单元格中求和相对数字的文本字符串。

doc总和文本号2

2。 然后在空白单元格中输入以下公式,在本例中,我将在单元格E1中输入公式: =SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)),然后按 Ctrl + Shift + Enter 键一起,它将基于特定文本从列表中返回总值。 看截图:

doc总和文本号3

小技巧:在上面的公式中, D1 是你想要使用的标准 B2:B8 表示您想要求和的单元格范围。

3。 然后选择公式cel,然后将填充手柄向下拖动到要应用此公式的单元格以获得结果:

doc总和文本号4


包含文本和数字的单元格忽略使用用户定义函数的文本


如果您有以下数据与文本和数字混合在一起,而您只想提取并添加每个单元格中的数字,那么您如何在Excel中快速完成此操作?

doc总和文本号5

要处理这个问题,你可以创建一个 用户自定义函数,请这样做:

1。 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications窗口.

2。 点击 插页 > 模块,并将以下代码粘贴到 模块窗口.

VBA代码:只汇总包含数字和文本的单元格中的数字

Function SumNumbers(rngS As Range, Optional strDelim As String = " ") As Double
'Update 20141210
    Dim xNums As Variant, lngNum As Long
    xNums = Split(rngS, strDelim)
    For lngNum = LBound(xNums) To UBound(xNums) Step 1
        SumNumbers = SumNumbers + Val(xNums(lngNum))
    Next lngNum
End Function

3。 然后保存并关闭此代码,返回到工作表,并输入此公式 = SumNumbers(A1) (A1 表示要对数字进行求和的单元格),然后将填充句柄向下拖动到要填充公式的单元格中,并且只将每个单元格中的数字相加,请参阅截图:

doc总和文本号6


将单元格内的所有单个数字相加

将单元格内的所有单个数字相加

如果你想把一个单元格中的所有数字相加, Kutools for Excel总和数字在一个单元格中 可以帮助您快速将一个号码的所有数字相加在一个单元格中。

doc总和文本号7

Kutools for Excel:比200方便的Excel加载项,可以在60天免费试用。 下载并免费试用现在!


相关文章:

如何在Excel中总结每n行?

如何根据Excel中的文本条件来求和值?


Kutools for Excel解决了您的大多数问题,并使您的生产率提高了80%

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能30天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Yuri · 3 months ago
    Thank you very much!!!
  • To post as a guest, your comment is unpublished.
    jasmeet · 6 months ago
    In this formula =SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)) can be put a range in place of D1 - say D1:D5 - not getting result, if i put it this way. What is the correct way to do this?
  • To post as a guest, your comment is unpublished.
    NP · 7 months ago
    Hi, I want to be able to add a number and also text to one cell (C5 all the way to C16) then get only the numbers in there to add up. But the =SumNumbers(A1) formula doesn't seem to work.
  • To post as a guest, your comment is unpublished.
    Emmy du Plooy · 11 months ago
    Hi, I hope someone can help. I like to add inside the cell +100j+50f+600m but must display/add on cell as 750 only. So you see 750 in cell but when press F2, it will show =100j+50f+600m
  • To post as a guest, your comment is unpublished.
    David · 1 years ago
    Hi. Please can someone help me. I am trying to SUM a column in EXCEL that has numbers and letters. eg 8.1km, 10.5km etc. There are 1031 lines or cells in the column. I am using this formula =SUM(LEFT(D3),LEN(D3)-2+LEFT(D4),LEN(D4)-2) which works if i want to add 2 or 3 cells together but i cant use this for 1031 cells. i wanted to add a : in place of the + but it comes back with an error and will not allow me to create the formula. Any help will be greatly appreciated
  • To post as a guest, your comment is unpublished.
    Mrityunjay · 1 years ago
    Hi,
    How to multiply 10 pcs *200,

    not 10*200
  • To post as a guest, your comment is unpublished.
    Giovanni · 1 years ago
    Hi,

    Thank you for this post! I am keen on using the VBA code and I was thinking if it would be possible to have a multivariable function so that you can sum the numbers from different column cells and write something like SumNumbers(A1:C1), for example.


    Many Thanks


    Giovanni
  • To post as a guest, your comment is unpublished.
    Anna · 2 years ago
    hi can anyone help me how to add below numbers with letters? i tried to do like but it doest work i think i miss something in the formula=SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)). please help.Thanks.

    2L
    5D
    10S
    3L
    11D
    16S
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hello, Anna,
      First, you should extract the letters into another helper column, and then apply the above formula, after entering this formula, please remember to press Shift + Ctrl + Enter keys together. see the following screenshot image:
  • To post as a guest, your comment is unpublished.
    JudyW · 2 years ago
    Hi There! I have two types of numbers in one column, one is numeric numbers, the other is a character followed by a number (such as n20, n30, etc). I wish to add up those numbers with an "n". I applied your guidance for "Sum Cells Containing Text And Numbers Based On The Certain Text With Formula", but it did not work. Is there any other method? Thanks in advance!
  • To post as a guest, your comment is unpublished.
    Ravi Sharma · 2 years ago
    April May June July Total
    1100 / 65658 1200/65657 1500/65656 2100/65650 ?

    i want to total only 1100+1200+1500+2100
    Other not a value only Receipt no. please help any
  • To post as a guest, your comment is unpublished.
    Ravi Sharma · 2 years ago
    How To Sum of selected word in cell in excel

    Exam

    1100/656480

    1100 is a amount and 656480 is recpt. no. but i want to total only 1100
  • To post as a guest, your comment is unpublished.
    Laura · 2 years ago
    Hello,
    The =SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)) - worked perfectly, except that my text is on the right.
    I tried to change the formula however that is not working... i just keep getting #VALUE!

    Can anyone help?
    • To post as a guest, your comment is unpublished.
      LeRoy · 2 years ago
      Remember to press Ctrl+Shift+Enter after changing the formula, not just Enter.
  • To post as a guest, your comment is unpublished.
    Colt · 2 years ago
    Can anyone help me with a sum formula?
    I'm trying to sum a column with cells that contain both numbers and text.
    I want to sum the numbers to the left of the text letter. sample:
    3P30
    2P30
    2P30
    2P30
    1P20
    3P30
    1P20
    3P50
    3P30
    3P60
  • To post as a guest, your comment is unpublished.
    Angela · 2 years ago
    How to include decimals in the "=SumNumbers(A1)" formula?
    Thank you!
  • To post as a guest, your comment is unpublished.
    Gil Michael Regalado · 2 years ago
    Here's a simple script that accepts single dimension and 2 dimensional selection range of cells with each cell containing string or numbers but with each cell reduced to single numbers and returns the sum of all cells.


    Option Explicit

    Function SUMCELLS(InputRange As Range) As Double
    Dim Arr() As Variant
    Arr = InputRange
    Dim R As Long
    Dim C As Long
    SUMCELLS = 0

    For R = 1 To UBound(Arr, 1) ' First array dimension is rows.
    For C = 1 To UBound(Arr, 2) ' Second array dimension is columns.
    Debug.Print Arr(R, C)
    Dim NumericValue As Double
    Dim StringValue As String

    StringValue = Trim(CStr(Arr(R, C)))
    If (Not (StringValue = "")) Then
    NumericValue = ONLYDIGITS(StringValue)
    SUMCELLS = SUMCELLS + NumericValue
    End If
    Next C
    Next R
    End Function

    Function ONLYDIGITS(s As String) As String
    Dim retval As String
    Dim i As Integer

    Dim periods As Integer
    periods = 0

    retval = ""
    '
    For i = 1 To Len(s)
    Dim char As String
    char = Mid(s, i, 1)
    If (char >= "0" And char
  • To post as a guest, your comment is unpublished.
    Kimberly Koester · 2 years ago
    I was able to use this formula perfectly, but I would also like to add a condition to only include certain numbers in the SUM formula if the value in another column = "defects".

    My original formula (using your original post) is:
    =SUM(IF(ISNUMBER(FIND("hrs",E17:E38)),VALUE(LEFT(E17:E38,FIND("hrs",E17:E38)-1)),0))

    Where E17:E38 contains the text and numbers that I want to sum
    And B17:B38 contains the values "features" and "defects"

    How can I adjust the formula to only SUM those numbers in column E if the value in column B = "defects"?

    Thanks in advance!

    Kimberly,
  • To post as a guest, your comment is unpublished.
    fazlul haque · 2 years ago
    How to convert between text and number using KUTOOls ?
  • To post as a guest, your comment is unpublished.
    MIKE · 2 years ago
    GENUIS.... Thanks ever so much
  • To post as a guest, your comment is unpublished.
    Jenny · 2 years ago
    This is super helpful! I'm trying to get the ARRAY to work with a column of cells that each contains a decimal number and text (e.g. .2 A; .5 C; .1 X etc), and I keep getting a result of 0. If I change the numbers to whole numbers, the result is correct. Help?
  • To post as a guest, your comment is unpublished.
    kc · 2 years ago
    is the any way to rewrite the vba code to sum multi cells instead of one? I have about 8 columns of data and i want the sum at the end.
  • To post as a guest, your comment is unpublished.
    Paul Burchfield · 3 years ago
    Is it possible to change the SumNumbers formula to add all the numbers in a column of mixed cells? For example, each column has 1A, 2B, 3C and I would like the formula at the bottom of the column to tell me 6.
  • To post as a guest, your comment is unpublished.
    Madelene · 3 years ago
    The SumNumbers macro saved me many hours of manual work. Thank you!
  • To post as a guest, your comment is unpublished.
    sadekul islam · 4 years ago
    ok, i understood this. good luck.
  • To post as a guest, your comment is unpublished.
    tawhid · 4 years ago
    In A1 Cell of excel I input data as like 5+6+3+1-2
    And A2 Cell of excel give the Result 13
    how it possible in excel.
  • To post as a guest, your comment is unpublished.
    sadekul islam · 4 years ago
    i think you are real teacher and good man. good luck.