|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 hbdyyx 于 2014-11-24 12:06 编辑
13楼代码修正如下,生成的信息正确了
Sub test()
Dim r%, i%
Dim arr, brr
Application.ScreenUpdating = False
With Worksheets("sheet1")
r = .Cells(.Rows.Count, 1).End(xlUp).Row
arr = .Range("a2:f" & r)
End With
ReDim brr(1 To (Int(-1 * UBound(arr) / 2)) * (-1) * 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.Clear
.Range("c:c,g:g").NumberFormatLocal = "@"
.Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
r = .Cells(.Rows.Count, 2).End(xlUp).Row
.Rows("1:" & r).RowHeight = 25
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, j + 1)
.Font.Size = 12
.Font.Bold = True
End With
With .Cells(i + 1, j)
.Resize(3, 1).Merge
.Font.Name = "Times New Roman"
.Font.Size = 80
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With .Cells(i, j).Resize(4, 1)
.Borders.LineStyle = xlContinuous
End With
With .Cells(i, j + 1).Resize(4, 2)
.BorderAround LineStyle:=xlContinuous, Weight:=xlThin
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next
Next
End With
End Sub
生成座签.rar
(376.13 KB, 下载次数: 23)
|
评分
-
1
查看全部评分
-
|