回答:
次の解決策を提案したいのですが、スクリーンショットを確認してください。
ソースデータ範囲はA1:B7(ヘッダーを除く)です。
結果のデータ範囲はA11:B14です。
最初に一意の名前リストを作成し、セルA11にこの式を記述します。
{= IFERROR(INDEX($ A $ 2:$ A $ 7、MATCH(0、COUNTIF($ A $ 11:A11、$ A $ 2:$ A $ 7)、0))、 "")}
最終結果については、B11に式を書きます。
{= IFERROR(INDEX($ B $ 2:$ B $ 7、SMALL(IF($ A11 = $ A $ 2:$ A $ 7、ROW($ A $ 2:$ A $ 7)-ROW($ A $ 2)+1)、 COLUMN(A1)))、 "")}
フォーミュラ1セルをドラッグしてから、必要になるまで下にドラッグします。
これがあなたのお役に立てば幸いです。私がテストした後、私はソリューションを投稿しました。
Nevermindは、非常にうまく機能するコードを見つけました。
Option Explicit
Function LookupCSVResults(lookupValue As Variant, lookupRange As Range,
resultsRange As Range) As String
Dim s As String 'Results placeholder
Dim sTmp As String 'Cell value placeholder
Dim r As Long 'Row
Dim c As Long 'Column
Const strDelimiter = "|||" 'Makes InStr more robust
s = strDelimiter
For r = 1 To lookupRange.Rows.Count
For c = 1 To lookupRange.Columns.Count
If lookupRange.Cells(r, c).Value = lookupValue Then
'I know it's weird to use offset but it works even if the two ranges
'are of different sizes and it's the same way that SUMIF works
sTmp = resultsRange.Offset(r - 1, c - 1).Cells(1, 1).Value
If InStr(1, s, strDelimiter & sTmp & strDelimiter) = 0 Then
s = s & sTmp & strDelimiter
End If
End If
Next
Next
'Now make it look like CSV
s = Replace(s, strDelimiter, ",")
If Left(s, 1) = "," Then s = Mid(s, 2)
If Right(s, 1) = "," Then s = Left(s, Len(s) - 1)
LookupCSVResults = s 'Return the function
End Function