以K為主,C為第二選擇順序排列好,然後再參考K的名稱,將K中每一類別的單號分類合併在各M行中, 以","作為分隔。

以K為主,C為第二選擇順序排列好,然後再參考K的名稱,將K中每一類別的單號分類合併在各M行中, 以","作為分隔。

Sub combinelotno()
Set d = CreateObject("Scripting.Dictionary")
For Each a In Range([K2], [K2].End(xlDown))
   If d(a.Value) = "" Then
      d(a.Value) = a.Offset(, -8)
      Else
      d(a.Value) = d(a.Value) & "," & a.Offset(, -8)
    End If
Next
[L:N] = ""
[L2].Resize(d.Count, 1) = Application.Transpose(d.keys)
[M2].Resize(d.Count, 1) = Application.Transpose(d.items)
End Sub

沒有留言:

張貼留言