- Sub 台账汇总计算()
- Dim nRow, arr
- Application.ScreenUpdating = False
- With Sheets("台账汇总")
- nRow = .Range("a" & .Rows.Count).End(3).Row
- arr = .Range("a5:bw" & nRow)
- aarr = .Range("a5:aj" & nRow)
- End With
-
- For i = 1 To UBound(arr)
- sm = 0
- For k = 7 To 26
- sm = arr(i, k) + sm
- Next k
- If sm = 0 Then
-
- For k = 27 To 36
- aarr(i, k) = ""
- Next k
- Else
- aarr(i, 27) = 0
- For k = 7 To 26
- aarr(i, 27) = arr(i, k) + aarr(i, 27)
- Next k
- aarr(i, 28) = arr(i, 7) + arr(i, 9) + arr(i, 11) + arr(i, 13)
- aarr(i, 29) = arr(i, 8) + arr(i, 10) + arr(i, 12) + arr(i, 14)
- aarr(i, 30) = arr(i, 15)
- aarr(i, 31) = arr(i, 16)
- aarr(i, 32) = arr(i, 17) + arr(i, 19) + arr(i, 21) + arr(i, 23)
- aarr(i, 33) = arr(i, 18) + arr(i, 20) + arr(i, 22) + arr(i, 24)
- aarr(i, 34) = arr(i, 25)
- aarr(i, 35) = arr(i, 26)
- aarr(i, 36) = 0
- For k = 27 To 35
- aarr(i, 36) = arr(i, k) + aarr(i, 36)
- Next k
-
- End If
-
- Next i
-
- Sheets("台账汇总").Range("aa5:aj" & nRow) = aarr
- Application.ScreenUpdating = True
- End Sub
复制代码
修改完,可以运行,但是逻辑上是否满足楼主需求,请楼主核实吧 |