Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从字符串值、excel中添加数字_Excel_String_Excel Formula - Fatal编程技术网

从字符串值、excel中添加数字

从字符串值、excel中添加数字,excel,string,excel-formula,Excel,String,Excel Formula,我有一个具有特定字符串值的表。SP-1,SP-2,SP-3,。。SP-8 还有V-4和V-8。我想添加字符串中的数字。字符串将相同(SP-或V-)。字符串后面的数字将不同。对于每种字符串类型,总和应该是分开的 我看到了许多解决方案,但无法适应它们 该表可能包含空单元格。因此,我无法使用值函数 我想检查整个表中的所有SP字符串和V字符串,并计算每种类型的总和。我想用公式而不是宏来实现这一点。你们中有谁能帮我使用这个公式吗?使用这个数组公式: =SUM(IFERROR(--SUBSTITUTE($A

我有一个具有特定字符串值的表。SP-1,SP-2,SP-3,。。SP-8 还有V-4和V-8。我想添加字符串中的数字。字符串将相同(SP-或V-)。字符串后面的数字将不同。对于每种字符串类型,总和应该是分开的

我看到了许多解决方案,但无法适应它们

该表可能包含空单元格。因此,我无法使用值函数


我想检查整个表中的所有SP字符串和V字符串,并计算每种类型的总和。我想用公式而不是宏来实现这一点。你们中有谁能帮我使用这个公式吗?使用这个数组公式:

=SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))
作为一个数组公式,在退出编辑模式时,需要使用Ctrl-Shift-Enter而不是Enter进行确认


使用以下数组公式:

=SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))
作为一个数组公式,在退出编辑模式时,需要使用Ctrl-Shift-Enter而不是Enter进行确认


尝试以下用户定义的功能:

Public Function SpecialAdder(rng As Range, p As String) As Variant
    Dim L As Long, r As Range
    If p = "" Then
        SpecialAdder = Application.WorksheetFunction.Sum(rng)
        Exit Function
    End If

    SpecialAdder = 0
    L = Len(p)
    For Each r In rng
        If Left(r.Value, L) = p Then
            SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
        End If
    Next r
End Function
它将在工作表中使用,如:

=specialadder(A1:A100,"SP-")

尝试以下用户定义的功能:

Public Function SpecialAdder(rng As Range, p As String) As Variant
    Dim L As Long, r As Range
    If p = "" Then
        SpecialAdder = Application.WorksheetFunction.Sum(rng)
        Exit Function
    End If

    SpecialAdder = 0
    L = Len(p)
    For Each r In rng
        If Left(r.Value, L) = p Then
            SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
        End If
    Next r
End Function
它将在工作表中使用,如:

=specialadder(A1:A100,"SP-")

我指的是31*12大小的表格(基本上是日历)。最后一个选项是增加一列。当为每个现有列添加此附加列时,我当然可以使用sumif。我用了下面的公式。但是value函数中的空单元格导致了#value错误。{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),value(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0))。}我所指的表大小是31*12(基本上是日历)。最后一个选项是增加一列。当为每个现有列添加此附加列时,我当然可以使用sumif。我用了下面的公式。但是value函数中的空单元格导致了#value错误。{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),value(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0))。}谢谢Scott。这很快就帮了忙。谢谢斯科特。这有助于快速行动。