|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("原始表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:f" & r)
- End With
- For i = 1 To UBound(arr)
- If Len(arr(i, 6)) <> 0 Then
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 1))(i) = Empty
- End If
- Next
- With Worksheets("目标表")
- .Cells.Clear
- r = 1
- For k = 1 To 5
- If d.exists(k) Then
- ReDim brr(1 To d(k).Count, 1 To 7)
- m = 0
- For Each bb In d(k).keys
- m = m + 1
- brr(m, 1) = m
- For j = 1 To UBound(arr, 2)
- brr(m, j + 1) = arr(bb, j)
- Next
- Next
- With .Cells(r, 1).Resize(1, 2)
- .Value = Array(k & "班", UBound(brr) & "人")
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- .Cells(r + 1, 1).Resize(1, 7) = Array("序号", "班级", "姓名", "地理", "生物", "类型", "需补考科目")
- .Cells(r + 2, 1).Resize(UBound(brr), UBound(brr, 2)) = brr
- With .Cells(r + 1, 1).Resize(1 + UBound(brr), UBound(brr, 2))
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- r = r + 2 + UBound(brr) + 1
- End If
- Next
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|