|
▼斉藤 さん:
もう一例、A〜Pを重複の削除機能で処理するパターンです。
8000件ぐらいなら、アップ済みのものとあまり効率はかわらないと思いますが。
Sub Sample2()
Dim c As Range
Dim dic As Object
Dim v As Variant
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("Sheet1")
v = .Range("A1").CurrentRegion.Columns("A:P").Value
For Each c In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
If Not dic.exists(c.Value) Then
dic(c.Value) = c.EntireRow.Range("Q1").Value
Else
dic(c.Value) = dic(c.Value) & "," & c.EntireRow.Range("Q1").Value
End If
Next
End With
With Sheets("Sheet2")
.Cells.ClearContents
.Range("A1").Resize(UBound(v, 1), UBound(v, 2)).Value = v
.Columns("A:P").RemoveDuplicates Columns:=1, Header:=xlYes
.Range("Q1").Resize(dic.Count).Value = WorksheetFunction.Transpose(dic.items)
.Select
End With
End Sub
|
|