参与一下。。。
- Sub ykcbf() '//2024.4.6
- Application.ScreenUpdating = False
- ReDim brr(1 To 10000, 1 To 11)
- Set sh = ThisWorkbook.Sheets("汇总统计")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- m = m + 1
- With sht
- brr(m, 1) = .Name
- r = .Cells(Rows.Count, 1).End(3).Row
- r1 = .UsedRange.Find("B仓库", LookIn:=xlValues).Row
- arr = .UsedRange
- p1 = 0: n = 0
- For i = 3 To r1 - 3
- p1 = p1 + IIf(arr(i, 11) = "不合格", arr(i, 10), 0)
- n = n + IIf(arr(i, 11) = "不合格", 1, 0)
- Next
- brr(m, 2) = r1 - 5
- brr(m, 3) = arr(r1 - 2, 10)
- brr(m, 4) = arr(r1 - 2, 8)
- brr(m, 5) = p1
- brr(m, 6) = n
- p1 = 0: n = 0
- For i = r1 + 2 To r - 2
- p1 = p1 + IIf(arr(i, 11) = "不合格", arr(i, 10), 0)
- n = n + IIf(arr(i, 11) = "不合格", 1, 0)
- Next
- brr(m, 7) = r - 3
- brr(m, 8) = arr(r - 1, 10)
- brr(m, 9) = arr(r - 1, 8)
- brr(m, 10) = p1
- brr(m, 11) = n
- End With
- End If
- Next
- With sh
- .UsedRange.Offset(1).ClearContents
- .[a2].Resize(m, 11) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|