|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("原始表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:i" & r)
- End With
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- If Not d(arr(i, 1)).exists(arr(i, 2)) Then
- Set d(arr(i, 1))(arr(i, 2)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 1))(arr(i, 2))(i) = Empty
- Next
- With Worksheets("目标表")
- .Cells.Clear
- r = 1
- For Each aa In d.keys
- For Each bb In d(aa).keys
- ReDim brr(1 To 30, 1 To 10)
- m = 1
- n = 1
- nan = 0
- nu = 0
- ty = 0
- For Each cc In d(aa)(bb).keys
- brr(m, n) = arr(cc, 3)
- brr(m, n + 1) = arr(cc, 4)
- brr(m, n + 2) = arr(cc, 5)
- brr(m, n + 3) = arr(cc, 6)
- m = m + 1
- If m > 30 Then
- m = 1
- n = 6
- End If
- If arr(cc, 5) = "男" Then
- nan = nan + 1
- Else
- nu = nu + 1
- End If
- If arr(cc, 6) = "团员" Then
- ty = ty + 1
- End If
- Next
- With .Cells(r, 1)
- .Value = aa & bb & "班名单"
- .Resize(1, 10).Merge
- With .Font
- .Name = "微软雅黑"
- .Size = 16
- End With
- End With
- With .Cells(r + 1, 1)
- .Value = "班主任:" & Space(6) & "人数" & d(aa)(bb).Count & "人,男" & nan & "人,女" & nu & "人,团员" & ty & "人"
- .Resize(1, 10).Merge
- End With
- .Cells(r + 2, 1).Resize(1, 10) = Array("序号", "姓名", "性别", "政治面貌", "备注", "序号", "姓名", "性别", "政治面貌", "备注")
- .Cells(r + 3, 1).Resize(UBound(brr), UBound(brr, 2)) = brr
- With .Cells(r + 2, 1).Resize(1 + UBound(brr), 5)
- .Borders.LineStyle = xlContinuous
- .BorderAround LineStyle:=xlDouble, Weight:=xlThick
- End With
- With .Cells(r + 2, 6).Resize(1 + UBound(brr), 5)
- .Borders.LineStyle = xlContinuous
- .BorderAround LineStyle:=xlDouble, Weight:=xlThick
- End With
- .Rows(r).RowHeight = 30
- .Rows(r + 1).Resize(2 + UBound(brr)).RowHeight = 18
- r = r + 2 + UBound(brr) + 1
- Next
- Next
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|