| 
    
     |  | 教えてください。 
 文字    数量1    数量2
 A1    10    100
 A1    20    200
 B1    30    300
 B1    40    400
 B2    50    500
 B2    60    600
 A2    70    700
 A2    80    800
 
 sheet1に上の表があり文字が重複していないデータの文字から数量2までを
 sheet2に抽出しようとしています。
 文字重複はdictionaryで対応でき数量1はとりだせましたが、数量2がうまく
 取り出せません。
 この取り出し方どなたか教えてください。
 初心者なのでわかりやすく説明頂けると助かります。
 dictionaryへのセットは理解できましたが取り出し方がわかりません。
 特にsheet2に出力する際のmyDic.Item(vKey)がいまいちわからないです
 
 お願いします。
 
 Sub sample3()
 
 Dim myDic As New Dictionary
 Dim i As Long
 
 Dim vals    As Variant
 Dim ovals    As Variant
 
 Dim a1     As String
 Dim a2     As String
 Dim a3     As String
 
 With Worksheets("Sheet1")
 For i = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row
 If Not myDic.Exists(.Cells(i, 1).Value) Then
 
 a1 = .Cells(i, 1).Value
 a2 = .Cells(i, 2).Value
 a3 = .Cells(i, 3).Value
 
 vals = Array(a2, a3)
 
 ''myDic.Add .Cells(i, 1).Value, .Cells(i, 2).Value
 myDic.Add a1, vals
 
 End If
 Next i
 End With
 
 Dim vKey As Variant
 With Worksheets("Sheet2")
 i = 0
 For Each vKey In myDic
 i = i + 1
 
 
 .Cells(i + 1, 1).Value = vKey
 .Cells(i + 1, 2).Value = myDic.Item(vKey)
 .Cells(i + 1, 3).Value = myDic.Item(1)
 
 
 Next
 End With
 Set myDic = Nothing
 End Sub
 
 |  |