|
Sub 考号()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("考场分布汇总")
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("a1:c" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" And Trim(ar(i, 3)) <> "" Then
d(Trim(ar(i, 1))) = d(Trim(ar(i, 1))) + ar(i, 3)
End If
Next i
With Sheets("考场编排")
rs = .Cells(Rows.Count, 8).End(xlUp).Row
.Range("e2:f" & rs + 1) = Empty
br = .Range("e1:h" & rs)
m = 1
For Each k In d.keys
kc = k
sl = d(k)
For s = 1 To sl
m = m + 1
br(m, 1) = Format(kc, "00")
br(m, 2) = Format(s, "00")
Next s
Next k
.Range("e1:h" & rs) = br
End With
MsgBox "ok!"
End Sub
|
|