|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim lk
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- lk = [{8,38,9.63,8.50,9.63}]
- With Worksheets("考号")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a3:h" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 5)) Then
- m = 1
- ReDim brr(1 To m)
- Else
- brr = d(arr(i, 5))
- m = UBound(brr) + 1
- ReDim Preserve brr(1 To m)
- End If
- brr(m) = i
- d(arr(i, 5)) = brr
- Next
- End With
- For Each aa In d.keys
- brr = d(aa)
- wjm = aa & "考室桌贴"
- On Error Resume Next
- Set ws = Worksheets(wjm)
- If Err Then
- Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
- ws.Name = wjm
- End If
- On Error GoTo 0
- With Worksheets(wjm)
- .Columns("a:i").NumberFormatLocal = "@"
- .Cells.Clear
- m = 1
- n = 1
- For i = 1 To UBound(brr)
- q = brr(i)
- .Cells(m, n).Resize(3, 1) = [{"姓名";"考室";"考号"}]
- .Cells(m, n + 2).Resize(2, 1) = [{"班级";"座号"}]
- .Cells(m, n + 1) = arr(q, 4)
- .Cells(m + 1, n + 1) = arr(q, 5)
- .Cells(m + 2, n + 1) = arr(q, 7)
- .Cells(m, n + 3) = arr(q, 8)
- .Cells(m + 1, n + 3) = arr(1, 7)
- With .Cells(m, n).Resize(3, 4)
- .Borders.LineStyle = xlContinuous
- End With
- n = n + 5
- If n > 6 Then
- m = m + 4
- n = 1
- End If
- Next
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- With .Range("a:a,c:c,f:f,h:h")
- With .Font
- .Bold = True
- End With
- End With
- With .Range("a1:i" & r)
- With .Font
- .Size = 10
- End With
- End With
- .Rows("1:" & r).RowHeight = 14.25
- .Columns("a:i").AutoFit
- For j = 1 To UBound(lk)
- .Rows(j).ColumnWidth = lk(j)
- .Rows(j + 5).ColumnWidth = lk(j)
- Next
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Next
- End Sub
复制代码 |
|