|
消息收到,修改代码如下,请自行测试结果:
- Sub test()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Sheets("总表")
- r = .Cells(.Rows.Count, 5).End(xlUp).Row
- arr = .Range("e5:j" & r)
- End With
- ReDim brr(1 To UBound(arr), 1 To 6)
- For Each sht In Sheets
- If sht.Name <> ActiveSheet.Name Then
- With sht
- xm = .[i1]
- m = 0
- For i = 1 To UBound(arr)
- If arr(i, 6) = xm Then
- m = m + 1
- For j = 1 To 5
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- For i = 2 To UBound(brr)
- If brr(i, 1) = 0 Or brr(i, 1) = "" Then
- brr(i, 6) = .[d1] - brr(i - 1, 1)
- Else
- brr(i, 6) = brr(i, 1) - brr(i - 1, 1)
- End If
- Next
- .Range("e5:i" & .Rows.Count).ClearContents
- .Range("e5").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- End If
- Next
- Application.ScreenUpdating = True
- MsgBox "数据计算完毕!"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|