|
Sub OnetoTwo()
Dim arr, brr
Dim Dic As Object, Eic As Object
Dim i, j, k, n
Dim str As String, ttr As String
Set Dic = CreateObject("scripting.dictionary")
Set Eic = CreateObject("scripting.dictionary")
arr = Sheets("1维").Range("a1").CurrentRegion
For i = 2 To UBound(arr)
Dic(arr(i, 4)) = ""
Next
ttr = Join(Dic.keys, "")
'MsgBox ttr
ReDim brr(1 To 20000, 1 To 3 + Dic.Count)
For j = 2 To UBound(arr)
str = arr(j, 1) & "-" & arr(j, 2) & "-" & arr(j, 3)
x = InStr(ttr, arr(j, 4)) / 2 + 0.5
If Eic.exists(str) Then
k = Eic(str)
brr(k, 3 + x) = arr(j, 5)
Else
n = n + 1
Eic(str) = n
brr(n, 1) = arr(j, 1)
brr(n, 2) = arr(j, 2)
brr(n, 3) = arr(j, 3)
brr(n, 3 + x) = arr(j, 5)
End If
Next
With Sheets("二维")
.Cells.ClearContents
.Columns("b:b").NumberFormatLocal = "@"
.Range("a1:c1") = Array("班级", "考号", "姓名")
.Range("d1").Resize(, Dic.Count) = Dic.keys
.[a2].Resize(n, 3 + Dic.Count) = brr
End With
End Sub |
|