|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Application.ScreenUpdating = False
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- If (r - 1) Mod 2 = 1 Then
- r = r + 1
- End If
- arr = .Range("a2:f" & r)
- End With
- ReDim brr(1 To (UBound(arr) / 2) * 5, 1 To 7)
- m = 1
- For i = 1 To UBound(arr) Step 2
- For k = 1 To 2
- brr(m, k * 4 - 3) = "第" & arr(i + k - 1, 1) & "考场"
- brr(m, k * 4 - 2) = "姓 名"
- brr(m, k * 4 - 1) = arr(i + k - 1, 4)
- brr(m + 1, k * 4 - 3) = arr(i + k - 1, 2)
- brr(m + 1, k * 4 - 2) = "准考证号"
- brr(m + 1, k * 4 - 1) = arr(i + k - 1, 3)
- brr(m + 2, k * 4 - 2) = "身份证号"
- brr(m + 2, k * 4 - 1) = arr(i + k - 1, 5)
- brr(m + 3, k * 4 - 2) = "岗位名称"
- brr(m + 3, k * 4 - 1) = arr(i + k - 1, 6)
- Next
- m = m + 5
- Next
- With Worksheets("sheet2")
- .Cells.Delete
- .Range("c:c,g:g").NumberFormatLocal = "@"
- .Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- For i = 1 To r Step 5
- For j = 1 To 5 Step 4
- With .Cells(i, j)
- .Font.Size = 18
- .Font.Bold = True
- End With
- With .Cells(i + 1, j)
- .Resize(3, 1).Merge
- .Font.Name = "Times New Roman"
- .Font.Size = 80
- End With
- With .Cells(i, j).Resize(4, 3)
- .Borders.LineStyle = xlContinuous
- .BorderAround LineStyle:=xlContinuous, Weight:=xlThin
- With .Borders(xlInsideHorizontal)
- .LineStyle = xlContinuous
- .Weight = xlThin
- .ColorIndex = xlAutomatic
- End With
- End With
- Next
- Next
- For i = 21 To r Step 20
- .HPageBreaks.Add Before:=.Rows(i)
- Next
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .Rows.RowHeight = 34
- End With
- .Columns("a:g").AutoFit
- .Columns("d:d").ColumnWidth = 1.5
- End With
- MsgBox "座签生成完毕!"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|