|
楼主 |
发表于 2023-8-9 10:21
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
大神,问题找到了:
Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
brr = Sheets("班级").[c1:h1]
arr = Sheets("班级").UsedRange
For j = 2 To UBound(arr)
If Len(arr(j, 2)) > 0 Then
If Not d.exists(arr(j, 2)) Then
Set d(arr(j, 2)) = CreateObject("scripting.dictionary")
End If
d(arr(j, 2))(j) = ""
End If
Next j
Application.ScreenUpdating = False
r = 1
With Sheets("考场座位表")
.UsedRange.ClearContents
For Each k In d.keys
.Cells(r, 2).Resize(1, 6) = brr
.Cells(r, 9).Resize(1, 6) = brr
c = -1
rx = 1
For Each kk In d(k).keys
If rx = 31 Then
c = 6
rx = 1
End If
For i = 3 To 8
.Cells(rx + r, c + i) = arr(kk, i)
Next i
rx = rx + 1
Next kk
r = r + 31
Next k
End With
Application.ScreenUpdating = True
End Sub
只要把 If rx = 32 Then这句中的32改成31即可! |
|