ID非公開

2022/6/27 13:26

22回答

Excelの関数かマクロついて教えてください。

画像

ベストアンサー

0
画像

その他の回答(1件)

0

マクロでよろしければ。。。 こんな感じでしょうか。 Option Explicit Sub Sample() Dim Dic, i As Long, buf As String, Keys, Keys2 Dim j As Long, m As Long, n As Long, maxR As Long Set Dic = CreateObject("Scripting.Dictionary") maxR = Cells(Rows.Count, "A").End(xlUp).Row For i = 2 To maxR buf = Cells(i, "A").Value If Not Dic.Exists(buf) Then Dic.Add buf, buf End If Next i Keys = Dic.Keys Set Dic = Nothing n = 0 For i = 0 To UBound(Keys) Set Dic = CreateObject("Scripting.Dictionary") For j = 2 To maxR If Keys(n) = Cells(j, "A").Text Then buf = Cells(j, "B").Value If Not Dic.Exists(buf) Then Dic.Add buf, buf End If End If Next j Keys2 = Dic.Keys Set Dic = Nothing For j = 2 To maxR If Keys(n) = Cells(j, "A").Text Then For m = 0 To UBound(Keys2) Cells(j, m + 4) = Keys2(m) Next m n = n + 1 Exit For End If Next j Next i End Sub