AW: Zwischensummen getrennt in positiv und negativ
19.08.2004 19:07:13
Roland
Hallo Martin,
wenn es auch ein VBA-Ansatz sein darf: folgenden Code in ein Modul und von Tabelle1 aus starten:
Sub sortieren()
Dim i As Long, j As Long, dblSumme As Double
Application.ScreenUpdating = False
Range("B4:C" & Range("C65536").End(xlUp).Row).Select
Selection.Sort Key1:=Range("C4"), Order1:=xlAscending
For i = 4 To Range("C65536").End(xlUp).Row
dblSumme = 0
j = 0
Do
dblSumme = dblSumme + Range("B" & i + j).Value
Range("E" & i + j).Value = dblSumme
j = j + 1
Loop While Range("C" & i + j).Value = Range("C" & i + j + 1).Value
dblSumme = dblSumme + Range("B" & i + j).Value
Range("E" & i + j).Value = dblSumme
If dblSumme >= 0 Then
Range("F" & i, Range("F" & i + j)).Value = Range("E" & i, Range("E" & i + j)).Value
Else
Range("G" & i, Range("G" & i + j)).Value = Range("E" & i, Range("E" & i + j)).Value
End If
Range("E" & i, Range("E" & i + j)).ClearContents
i = i + j
Next
Range("B4").Select
Application.ScreenUpdating = True
End Sub
Wenn du zwischendurch mal ein Kriterium änderst, müsste er das richtig einsortieren.
Gruß
Roland