|
楼主 |
发表于 2023-1-3 09:16
|
显示全部楼层
Sub TEST6()
Dim arr, brr, vData, i&, j&, R&, dic As Object, vKey, iPosRow&
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
brr = [{"年级","班级","语文","数学","物理","历史","化学","英语","班主任"}]
arr = [A1].CurrentRegion.Resize(, 5)
ReDim vData(1 To UBound(arr), 1 To 9)
For i = 1 To UBound(brr)
vData(1, i) = brr(i)
dic(brr(i)) = i
Next
R = 1
For i = 3 To UBound(arr)
brr = Split(arr(i, 5), "、")
For j = 0 To UBound(brr)
vKey = arr(i, 3) & Val(brr(j)) & "班"
If Not dic.exists(vKey) Then
R = R + 1
dic(vKey) = R
vData(R, 1) = arr(i, 3)
vData(R, 2) = Val(brr(j)) & "班"
End If
iPosRow = dic(vKey)
If arr(i, 4) <> "" Then
vData(iPosRow, dic(arr(i, 4))) = arr(i, 1)
End If
If arr(i, 2) = "班主任" Then
vData(iPosRow, dic(arr(i, 2))) = arr(i, 1)
End If
Next j
Next i
Columns("L:Q").ClearContents
[L1].Resize(R, 9) = vData
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
老师,我这样改了,能统计与计算了,但又没有框线了,谢谢!! |
|