|
B2 下拉及右拉
- =SumMultipleSheets($A2,$A2,B$1,EOMONTH(B$1,0))
复制代码
- Function SumMultipleSheets(criteriaRange As Range, criteriaValue As Variant, startDate As Date, endDate As Date) As Double
- Dim sheetNames As Variant
- Dim totalSum As Double
- Dim ws As Worksheet
- Dim criteriaColumn As Range
- Dim sumRange As Range
- Dim dateRange As Range
- sheetNames = Array("中", "天", "时", "风")
- totalSum = 0
- For Each wsName In sheetNames
- On Error Resume Next
- Set ws = ThisWorkbook.Worksheets(wsName)
- On Error GoTo 0
- If Not ws Is Nothing Then
- Set sums = ws.Range("G:G")
- Set criteriaColumn = ws.Range("A:A")
- Set dateRange = ws.Range("H:H")
- totalSum = totalSum + Application.SumIfs(sums, criteriaColumn, criteriaValue, dateRange, ">=" & startDate, dateRange, "<=" & endDate)
- End If
- Next wsName
- SumMultipleSheets = totalSum
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|