在合并的单元格下求和项目

我想请求帮助来总结合并单元格下的所有项目。 项目看起来像这样:

June 0 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 0 1 

六月份是一个合并的单元格,我想把它下面的所有项目加起来。 这甚至有可能吗?

无论单元格是合并还是非合并,这都会起作用。 假设我们已经将A1C2合并为以下内容:

在这里输入图像描述

下面的UDF()将给出数值的总和:

 Public Function InternalSum(rin As Range) As Double Dim v As String, CH As String, temp As String Dim dot As String, L As Long, i As Long Dim capture As Boolean v = rin(1).Text InternalSum = 0 dot = "." temp = "" capture = False L = Len(v) If L = 0 Then Exit Function For i = 1 To L CH = Mid(v, i, 1) If IsNumeric(CH) Or CH = dot Then capture = True temp = temp & CH If i = L Then InternalSum = InternalSum + CDbl(temp) End If Else If capture Then capture = False InternalSum = InternalSum + CDbl(temp) temp = "" End If End If Next i End Function 

在这里输入图像说明

请注意,两者:

 =internalsum(A1) 

 =internalsum(A1:C2) 

将工作。