|
- Sub 汇总()
- Dim d As Object, dx As Object, arr, i%, j%, k
- Dim Rng As Range
- Set d = CreateObject("Scripting.Dictionary")
- Set dx = CreateObject("Scripting.Dictionary")
- Rem 提取部頒计划
- arr = Sheet1.Range("C20:R26") '
- For i = 2 To UBound(arr)
- For j = 1 To UBound(arr, 2)
- d(arr(1, j) & "|" & i - 1) = arr(i, j)
- Next
- Next
- Rem 提取任课教师姓名
- Dim x%, x1%, a()
- For Each Rng In Sheet1.Range("V2:V" & Sheet1.Range("V65536").End(3).Row)
- If Rng.Value <> "" Then
- x = x + 1: ReDim Preserve a(1 To 2, 1 To x)
- dx(Rng.Value) = x
- End If
- Next
- Rem 汇总工作量
- arr = Sheet1.Range("C1:S19")
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- If arr(i, j) <> "" Then
- k = arr(1, j) & "|" & Left(arr(i, 1), 1)
- If Not dx.Exists(arr(i, j)) Then
- x = x + 1: ReDim Preserve a(1 To 2, 1 To x)
- a(1, x) = 1
- a(2, x) = d.Item(k)
- dx(arr(i, j)) = x
- Else
- x1 = dx.Item(arr(i, j))
- a(1, x1) = a(1, x1) + 1
- a(2, x1) = a(2, x1) + d.Item(k)
- End If
- End If
- Next
- Next
- Sheet1.Range("W2").Resize(dx.Count, 2) = WorksheetFunction.Transpose(a)
- End Sub
复制代码 |
|