|
- Sub test1()
- Dim ar(1 To 256), Ran() As Range
- Dim i As Integer, j As Integer, k As Integer
-
- ReDim Ran(2 To Worksheets.Count) ' 或2 to 6, 指第2到第6个工作表
- For j = LBound(Ran) To UBound(Ran)
- Set Ran(j) = Worksheets(j).Range("A1:K2")
- Next
- For i = 0 To 3 '统计 0 到 3
- For j = LBound(Ran) To UBound(Ran) '统计各表相关区域
- k = k + 1
- ar(k) = WorksheetFunction.CountIf(Ran(j), i)
- Next
- Next
- For j = LBound(Ran) To UBound(Ran) '最后求和
- k = k + 1
- ar(k) = WorksheetFunction.Sum(Ran(j))
- Set Ran(j) = Nothing '释放
- Next
- With Worksheets(1).Range("C4")
- .Resize(, 256).ClearContents
- .Resize(, k) = ar
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|