|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- With Worksheets("座次表")
- r = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- c = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
- arr = .Range("a3").Resize(r - 2, c)
- End With
- With Worksheets("桌签")
- .Cells.ClearContents
- m = 1
- n = 1
- s = 0
- For i = 1 To UBound(arr)
- For j = 1 To UBound(arr, 2)
- If Len(arr(i, j)) <> 0 Then
- s = s + 1
- .Cells(m, n) = arr(i, j)
- .Cells(m, n + 1) = s
- n = n + 4
- If n > 5 Then
- n = 1
- m = m + 3
- End If
- If s Mod 10 = 0 Or (i = UBound(arr) And j = UBound(arr, 2)) Then
- .PrintOut
- .Cells.ClearContents
- m = 1
- n = 1
- End If
- End If
- Next
- Next
- End With
- End Sub
复制代码 |
|