|
- Sub 新座次表()
- Dim r%, i%, c%, j%
- Dim arr, kc, bt
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each ws In Worksheets
- If ws.Name Like "试场*" Then
- ws.Delete
- End If
- Next
- With Worksheets("考场信息")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- kc = .Range("a2:c" & r)
- End With
- With Worksheets("考生信息")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:e" & r)
- End With
- k = 1
- i = 1
- Do While i <= UBound(arr)
- ReDim brr(1 To 12, 1 To 12)
- brr(1, 1) = "第" & kc(k, 1) & "考场"
- brr(2, 1) = "考场地点:" & kc(k, 3)
- brr(2, 9) = "起止号:" & arr(i, 1)
- brr(3, 1) = "讲 台"
- For j = 1 To 10 Step 3
- brr(4, j) = "考号"
- brr(4, j + 1) = "姓名"
- brr(4, j + 2) = "座号"
- Next
- Select Case kc(k, 2)
- Case 30
- brr(5, 4) = "#"
- brr(5, 7) = "#"
- Case 29
- brr(5, 4) = "#"
- brr(5, 7) = "#"
- brr(5, 10) = "#"
- Case 28
- brr(5, 1) = "#"
- brr(5, 4) = "#"
- brr(5, 7) = "#"
- brr(5, 10) = "#"
- Case 27
- brr(5, 1) = "#"
- brr(5, 4) = "#"
- brr(5, 7) = "#"
- brr(5, 10) = "#"
- brr(6, 10) = "#"
- End Select
- s = 1
- m = 5
- n = 1
- Do While s <= kc(k, 2)
- If brr(m, n) <> "#" Then
- brr(m, n) = arr(i, 1)
- brr(m, n + 1) = arr(i, 2)
- brr(m, n + 2) = s
- i = i + 1
- s = s + 1
- End If
- If n Mod 2 = 1 Then
- m = m + 1
- If m = 13 Then
- m = 12
- n = n + 3
- End If
- Else
- m = m - 1
- If m = 4 Then
- m = 5
- n = n + 3
- End If
- End If
- If n = 13 Or s > kc(k, 2) Or i > UBound(arr) Then
- brr(2, 9) = brr(2, 9) & "-" & arr(i - 1, 1)
- d(k) = brr
- k = k + 1
- Exit Do
- End If
- Loop
- Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
- With ws
- .Name = "试场" & k - 1
- .Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- With .Cells(1, 1)
- .Font.Name = "黑体"
- .Font.Size = 20
- .Resize(1, 12).Merge
- End With
- With .Cells(2, 1)
- .Resize(1, 4).Merge
- End With
- With .Cells(2, 9)
- .Resize(1, 4).Merge
- End With
- With .Cells(3, 1)
- .Resize(1, 12).Merge
- End With
- .Range("a4:l12").Borders.LineStyle = xlContinuous
- .Columns("a:l").AutoFit
- .Rows("1:3").RowHeight = 40
- .Rows("4:12").RowHeight = 30
- With .UsedRange
- .Replace What:="#", Replacement:="", LookAt:=xlWhole, SearchOrder:=xlByRows
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- If k > UBound(kc) Then
- Exit Sub
- End If
- Loop
- End Sub
复制代码 |
|