VBAでよろしければ以下で試してみてください。
小計行の色は
Interior.Color = 14998742
の数値を変更して好みのものに合わせてください。
Sub Test()
Dim mRow As Long
Dim LastRow As Long, eRow As Long
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
eRow = LastRow
Range(Cells(LastRow, "A"), Cells(LastRow, "F")).Copy Cells(LastRow + 1, "A")
Cells(LastRow + 1, "A").Value = ""
For mRow = LastRow To 3 Step -1
If Cells(mRow, "B").Value <> Cells(mRow - 1, "B").Value Then
Call mSubtotal(mRow, eRow)
Rows(mRow).Insert
eRow = mRow - 1
End If
Next
Call mSubtotal(2, eRow)
Application.ScreenUpdating = True
End Sub
Sub mSubtotal(ByVal mRow As Long, ByVal eRow As Long)
Dim mStRow As Long
mStRow = eRow + 1
Cells(mStRow, "B").Value = "小計"
Cells(mStRow, "C").Value = WorksheetFunction.Sum(Range(Cells(mRow, "C"), Cells(eRow, "C")))
Cells(mStRow, "D").Value = WorksheetFunction.Sum(Range(Cells(mRow, "D"), Cells(eRow, "D")))
Cells(mStRow, "E").Value = WorksheetFunction.Sum(Range(Cells(mRow, "E"), Cells(eRow, "E")))
Cells(mStRow, "F").Value = WorksheetFunction.Sum(Range(Cells(mRow, "F"), Cells(eRow, "F")))
Range(Cells(mStRow, "A"), Cells(mStRow, "F")).Interior.Color = 14998742
End Sub
お礼