Ich habe diesen Code hier bekommen. Nun habe ich aber in meine Tabelle 3 Spalten neu eingefügt und die Summierung greift bei diesem Code auf die Spalten 4 (D) und 6 (F). Das mit der Monatlichen Summierung habe ich hinbekommen, jedoch ich komm einfach nicht dahinter, was ich ändern muß um die Endsumme aus allen Monaten in der letzten Spalte zu bekommen. Welche Zahlen muß ich ändern, das am Ende der Tabelle die Gesamtsumme aus allen Monaten steht.
Danke
chris
Public Sub prcSummenzeile()
Dim vntTemp1 As Variant, vntTemp2 As Variant
Dim lngRow As Long, lngLastRow As Long
Dim rngSummen As Range
lngLastRow = Cells(Rows.Count, 1).End(xlUp).Row
vntTemp1 = Month(Cells(lngLastRow, 1).Value)
For lngRow = lngLastRow To 3 Step -1
If lngRow > 3 Then
vntTemp2 = Month(Cells(lngRow, 1).Value)
Else
vntTemp2 = 0
End If
If vntTemp2 vntTemp1 Then
Rows(lngLastRow + 1).Insert
With Cells(lngLastRow + 1, 9)
.Formula = "=Sum(" & Range(Cells(lngRow + 1, 9), Cells(lngLastRow, 9)).Address & ")" _
_
.Font.Bold = True
End With
With Cells(lngLastRow + 1, 11)
.Formula = "=Sum(" & Range(Cells(lngRow + 1, 11), Cells(lngLastRow, 11)).Address & " _
_
)"
.Font.Bold = True
End With
Range(Cells(lngLastRow + 1, 1), Cells(lngLastRow + 1, 15)).Interior.Color = vbGreen
If vntTemp2 0 Then vntTemp1 = Month(Cells(lngRow, 1).Value)
If Not rngSummen Is Nothing Then
Set rngSummen = Union(rngSummen, Cells(lngLastRow + 1, 4))
Else
Set rngSummen = Cells(lngLastRow + 1, 9)
End If
lngLastRow = lngRow
End If
Next lngRow
lngLastRow = Cells(Rows.Count, 1).End(xlUp).Row
With Cells(lngLastRow + 2, 9)
.Formula = "=Sum(" & rngSummen.Address & ")"
.Font.Bold = True
End With
With Cells(lngLastRow + 2, 11)
MsgBox rngSummen.Offset(0, 2).Address
.Formula = "=Sum(" & rngSummen.Offset(0, 2).Address & ")"
.Font.Bold = True
End With
Range(Cells(lngLastRow + 2, 1), Cells(lngLastRow + 2, 15)).Interior.Color = vbRed
Application.ScreenUpdating = True
End Sub