|
- Sub kcmt() '考场门贴
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("设置")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(2, .Columns.Count).End(xlToLeft).Column
- sz = .Range("a3").Resize(r - 2, c)
- For i = 1 To UBound(sz)
- d1(CStr(sz(i, 2))) = i
- Next
- End With
- With Worksheets("名单")
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:e" & r)
- For i = 1 To UBound(arr)
- ssh = CStr(arr(i, 4))
- If Not d.exists(ssh) Then
- Set d(ssh) = CreateObject("scripting.dictionary")
- End If
- d(ssh)(i) = Empty
- Next
- End With
- With Worksheets("考场门贴")
- .Cells.Clear
- r = 1
- For Each aa In d.keys
- If d1.exists(aa) Then
- Z = d1(aa)
- hs = 0
- ls = 0
- For j = 4 To UBound(sz, 2)
- If hs < sz(1, j) Then
- hs = sz(1, j)
- End If
- Next
- For j = UBound(sz, 2) To 4 Step -1
- If Len(sz(Z, j)) <> 0 Then
- ls = j - 3
- Exit For
- End If
- Next
- ReDim brr(1 To hs, 1 To ls)
- m = 1
- n = 1
- s = -1
- kk = d(aa).keys
- For j = 4 To 3 + ls
- For i = 1 To sz(Z, j)
- s = s + 1
- If s > UBound(kk) Then
- GoTo 100
- End If
- brr(m, n) = "考号:" & arr(kk(s), 2) & vbLf & "姓名:" & arr(kk(s), 3) & vbLf & "座位号:" & arr(kk(s), 5)
- If n Mod 2 = 1 Then
- m = m + 1
- If m > sz(Z, j) Then
- m = sz(Z, j + 1)
- n = n + 1
- End If
- Else
- m = m - 1
- If m < 1 Then
- m = 1
- n = n + 1
- End If
- End If
- Next
- Next
- 100:
- With .Cells(r, 1)
- .Value = "教学质量监测第" & aa & "试室"
- .Resize(1, ls).Merge
- With .Font
- .Name = "微软雅黑"
- .Size = 18
- End With
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- For j = 1 To UBound(brr, 2)
- .Cells(r + 1, j).Value = "第" & j & "列"
- Next
- With .Cells(r + 1, 1).Resize(1, UBound(brr, 2))
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- .Bold = True
- End With
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- With .Cells(r + 2, 1).Resize(UBound(brr), UBound(brr, 2))
- .Borders.LineStyle = xlContinuous
- .Value = brr
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- .Rows(r).Resize(2).RowHeight = 36
- .Rows(r + 2).Resize(UBound(brr)).RowHeight = 63.75
- r = r + 2 + UBound(brr)
- End If
- Next
- End With
- End Sub
复制代码 |
|