Excel 公式:对名称为日期的多个工作表中的相同单元格值求和

Excel formula: To sum the same cell values from multiple sheets with names as dates

有没有办法将每个标签名称为日期的多个sheets(标签)的同一单元格的所有值相加,并在MasterSheet中显示总和值?

例如:

目前,我在“Oct-2020”单元格下的单元格中使用这个公式=SUM(INDIRECT("'*-"&MONTH(C2)&"-2020'!$E")),如下图所示,我将在Nov-20和Dec-20做同样的事情。

如您所见,我收到了这个“#REF!”错误。目前,我有两个选项卡,我试图从“13-10-2020”和“14-10-2020”中获取“$E$3”单元格值。但是,如果我只有一个 sheet(假设只有“14-10-2020”),我就能得到值。

有人知道我的公式是怎么回事吗?为什么它在只有一个 sheet(制表符)可供读取时有效,但在有多个 sheets(制表符)时不起作用,即使我使用“*”来包含所有日期。

请指教。提前谢谢你

您可以使用求和函数。
按照这个一步一步来,它会起作用的。

在您的 MasterSheet C3 中键入 =Sum(
单击 sheet 13-10-2020 和单元格 E3。
现在按住shift键。 单击最后一个 sheet,即 October,然后按 Enter。

现在您应该得到 10 月份所有 E3 的总和 sheets。

据我所知,没有公式可以做到这一点,但我很确定如果 sheet 名称遵循某种模式,它可以在 VBA 中完成。

我认为这应该可以解决您的问题:

Option Explicit

Sub sub_sum_up_months()
    Dim wks As Worksheet
    Dim nr_month As Integer, nr_year As Integer
    Dim str_month As String, str_year As String
    Dim c As Integer
    Dim my_Sum As Double

    For c = 3 To 5 ' Iterating over the columns "C" to "E"
        my_Sum = 0
    
        nr_month = month(Worksheets("MasterSheet").Cells(2, c).Value)
        If nr_month < 10 Then
            str_month = "0" & nr_month
        Else
            str_month = CStr(nr_month)
        End If
        
        nr_year = Year(Worksheets("MasterSheet").Cells(2, c).Value)
        str_year = CStr(nr_year)
        
        For Each wks In ThisWorkbook.Worksheets
            If Right(wks.Name, 4) = str_year And Left(Right(wks.Name, 7), 2) = str_month Then
                my_Sum = my_Sum + wks.Cells(3, 5) 'cells(3,5) is "E3"
            End If
        Next wks
        Worksheets("MasterSheet").Cells(3, c).Value = my_Sum
    Next c
End Sub