|
こんな感じでいかがでしょうか。^d^
Sub test()
Dim Dic As Object
Dim Ky As String
Dim InPath As String
Dim OutPath As String
Dim N As Integer
Dim D As String
Dim i As Integer
Set Dic = CreateObject("Scripting.Dictionary")
InPath = ThisWorkbook.Path & "\In.csv"
OutPath = ThisWorkbook.Path & "\Out.csv"
N = FreeFile
Open InPath For Input As #N
Do Until EOF(N)
Line Input #N, D
i = InStr(D, ",")
Ky = Left$(D, i - 1)
If Dic.Exists(Ky) Then
Dic.Item(Ky) = Dic.Item(Ky) & Mid$(D, i)
Else
Dic.Item(Ky) = D
End If
Loop
Close #N
D = join(Dic.Items, vbCrLf)
N = FreeFile
Open OutPath For Output As #N
Print #N, D
Close #N
Set Dic = Nothing
End Sub
|
|