Sub ddss()
Dim d As Object, d1 As Object, arr, i, a, n, arr1(), ar, m, j, k
Set d = CreateObject("scripting.dictionary")
Set d1 = CreateObject("scripting.dictionary")
arr = Range("a2:e" & Cells(Rows.Count, 1).End(xlUp).Row)
For i = 1 To UBound(arr)
If arr(i, 5) = "开放" Then
a = arr(i, 1) & arr(i, 2) & arr(i, 3)
If Not d.exists(a) Then
n = n + 1
d(a) = n
ReDim Preserve arr1(1 To 4, 1 To n)
arr1(1, n) = arr(i, 1)
arr1(2, n) = arr(i, 2)
arr1(3, n) = arr(i, 3)
arr1(4, n) = arr(i, 4)
Else
m = d(a)
arr1(4, m) = Join(Array(Application.Transpose(arr1(4, m)), arr(i, 4)))
ar = Application.Transpose(Split(arr1(4, m)))
For j = 1 To UBound(ar)
d1(ar(j, 1)) = ""
arr1(4, m) = Join(d1.keys)
Next
d1.RemoveAll
End If
End If
Next
For k = 1 To UBound(Application.Transpose(arr1))
arr1(4, k) = UBound(Application.Transpose(Split(arr1(4, k))))
Next
Range("i:m").ClearContents
Cells(1, "i").Resize(1, 4) = Array("观众编码", "观众来源城市", "观众来源市区", "观看过的场次")
Cells(2, "i").Resize(n, 4) = Application.Transpose(arr1)
End Sub |