|
▼たく さん:
dicには、配列も登録できます。
商品別集計も同じ感じでできると思います。
Sub 日時集計()
Dim dKey As String
Dim c As Range
Dim dic As Object
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("ソート")
For Each c In .Range("A1", .Range("A" & .Rows.Count).End(xlUp))
dKey = c.Value & vbTab & c.Offset(, 3).Value
If Not dic.exists(dKey) Then
dic(dKey) = Array(Empty, Empty, Empty, Empty, Empty)
End If
dic(dKey) = Array( _
c.Value, _
c.Offset(, 3).Value, _
c.Offset(, 4).Value, _
dic(dKey)(3) + c.Offset(, 7).Value, _
dic(dKey)(4) + c.Offset(, 9).Value)
Next
End With
With Worsheets.Add
.Name = "日時集計"
.Range("A1").Resize(dic.Count, 5).Value = _
WorksheetFunction.Transpose(WorksheetFunction.Transpose(dic.items))
.Select
End With
Set dic = Nothing
End Sub
|
|