|
Sub 提取教师名册()
Dim ar As Variant
Dim br()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("课程清单")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "课程清单为空!": End
ar = .Range("a1:b" & r)
End With
ReDim br(1 To UBound(ar), 1 To 2)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
If InStr(ar(i, 1), "|") > 0 Then
xm = Split(ar(i, 1), "|")(0)
t = d(xm)
If t = "" Then
k = k + 1
d(xm) = k
t = k
br(k, 1) = k
br(k, 2) = xm
End If
End If
End If
Next i
With Sheets("教师名册")
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(k, 2) = br
End With
MsgBox "ok!"
End Sub
|
|