Gruppe
Allgemein
Problem
Wie kann ich beim Wechsel zu einer neuen Artikelgruppe in einer Liste - abhängig vom 1. Buchstaben - eine Summenzeile eingefügen?
StandardModule: basMain
Sub InsertSums()
Dim iRow As Integer, iRowL As Integer, iStart As Integer
iRowL = Cells(Rows.Count, 1).End(xlUp).Row + 1
For iRow = iRowL To 2 Step -1
If Left(Cells(iRow, 1).Value, 1) <> _
Left(Cells(iRow - 1, 1).Value, 1) Then
Rows(iRow).Insert
iStart = iRow - 1
Do Until Left(Cells(iStart, 1).Value, 1) <> _
Left(Cells(iStart - 1, 1).Value, 1)
iStart = iStart - 1
If iStart = 1 Then Exit Do
Loop
Cells(iRow, 2).Value = _
WorksheetFunction.Sum( _
Range(Cells(iStart, 2), Cells(iRow - 1, 2)))
Cells(iRow, 1).Value = "Summe:"
End If
Next iRow
End Sub