Sub SumValues()
Dim total As Double
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "總表" Then ' 排除名稱為 "總表" 的工作表
Dim lastRow As Long
lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
Dim i As Long
For i = 1 To lastRow
If ws.Cells(i, "C").Value = "合計" Then
total = total + ws.Cells(i, "D").Value + ws.Cells(i, "E").Value
End If
Next i
End If
Next ws
Worksheets("總表").Range("E45").Value = total ' 將總和值回傳到總表的 E43 欄位
End Sub