|
Sub luru()
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
With Sheet1
y = .Cells(4, Columns.Count).End(xlToLeft).Column
ar = .Range(.Cells(4, 6), .Cells(10000, y))
For j = 2 To UBound(ar, 2)
If Trim(ar(1, j)) <> "" Then
d(Trim(ar(1, j))) = j
End If
Next j
r = .Cells(Rows.Count, 1).End(xlUp).Row
br = .Range("a4:b" & r)
For i = 2 To UBound(br)
If Trim(br(i, 1)) <> "" Then
If Not dc.exists(Trim(br(i, 1))) Then
dc(Trim(br(i, 1))) = br(i, 2)
Else
dc(Trim(br(i, 1))) = dc(Trim(br(i, 1))) & "|" & br(i, 2)
End If
End If
Next i
For Each K In dc.keys
m = d(Trim(K))
If m <> "" Then
t = .Cells(Rows.Count, m + 5).End(xlUp).Row - 2
MC = dc(K)
rr = Split(dc(K), "|")
For s = 0 To UBound(rr)
ar(t, m) = rr(s)
t = t + 1
Next s
End If
Next K
.Range(.Cells(4, 6), .Cells(10000, y)) = ar
End With
End Sub
|
|