|
我也凑个试试看 代码如下
Sub 一维转二维()
Dim Arr, brr(), crr, i, k, s, dic As Object
Set dic = CreateObject("scripting.dictionary")
Arr = Sheet1.[a1].CurrentRegion
ReDim brr(1 To UBound(Arr, 1), 1 To UBound(Arr, 2) * 2)
For i = 2 To UBound(Arr, 1)
s = Arr(i, 8)
If Not dic.exists(s) Then
k = k + 1
dic(s) = k
brr(k, 1) = Arr(i, 8)
brr(k, 2) = Arr(i, 2)
Else
brr(dic(s), 2) = brr(dic(s), 2) & "|" & Arr(i, 2)
End If
Next
For i = 1 To UBound(brr)
crr = Split(brr(i, 2), "|")
For k = 0 To UBound(crr)
brr(i, k + 2) = crr(k)
Next
Next
Range("m10").Resize(UBound(brr), UBound(brr, 2)) = brr
End Sub |
评分
-
1
查看全部评分
-
|