'処理結果を蓄えるための DataTable Dim dt As New DataTable() dt.PrimaryKey = New DataColumn() {dt.Columns.Add("担当者名")} '加工結果を蓄えるための Dictionary Dim dicGyou As New Dictionary(Of String, Dictionary(Of String, String))() 'DataTable の各行を列挙する ' Recordset の場合は For Each ではなく、MoveNext 呼び出しに置き換えてください For Each row As DataRow In 元データのテーブル.Rows Dim dicRetu As Dictionary(Of String, String) Dim sStaff As String = CStr(row("担当者名")) Dim gDay As String = CStr(row("業務完了日")) '元データが日付型の場合は Format して取得すること Dim sClient As String = CStr(row("取引先名")) '行見出しの捜索 If dicGyou.ContainsKey(sStaff) Then dicRetu = dicGyou(sStaff) Else dicRetu = New Dictionary(Of String, String)() dicGyou.Add(sStaff, dicRetu) End If '列見出しの捜索 If dicRetu.ContainsKey(gDay) Then dicRetu(gDay) &= "、" & sClient '取引先名を連結 Else dicRetu.Add(gDay, sClient) '最初の取引先 If Not dt.Columns.Contains(gDay) Then '未登録の列見出しを追加 dt.Columns.Add(gDay, GetType(String)).AllowDBNull = True End If End If Next 'Dictionary を DataTable に詰めなおす For Each entry1 As KeyValuePair(Of KeyValuePair(Of String, String), String) In dic Dim newRow As DataRow = dt.NewRow() newRow("担当者名") = entry1.Key dt.Rows.Add(newRow) For Each entry2 As KeyValuePair(Of String, String) In entry1.Value newRow(entry2.Key) = entry2.Value Next Next dt.AcceptChanges()