| 
    
     |  | ▼迷える羊 さん: 
 Sub test()
 Dim ws1 As Worksheet, ws2 As Worksheet
 Dim c As Range
 Dim d As Object, k
 Dim v, i As Long, s As String
 Dim a As Object
 
 Set ws1 = Sheets("Sheet1")
 Set ws2 = Sheets("Sheet2")
 Set d = CreateObject("scripting.dictionary")
 
 For Each c In ws1.Columns(1).SpecialCells(xlCellTypeConstants)
 Set d(c.Value) = CreateObject("system.collections.arraylist")
 Next
 
 v = ws2.Cells(1).CurrentRegion.Value
 For i = 1 To UBound(v)
 s = v(i, 2)
 If d.exists(s) Then d(s).Add v(i, 1)
 Next
 
 Set a = CreateObject("system.collections.arraylist")
 
 For Each k In d.keys
 a.addrange dic(k)
 Next
 
 ws1.Cells(2).Resize(a.Count).Value = Application.Transpose(a.toarray)
 
 End Sub
 
 
 |  |