Nochmal Frage Makro Ende ...
Kurt
ich habe gerade festgestellt, die Summen in der Spalte 19 + 32(habe dazu genommen) ,
werden soweit reingesetzt über die letzte Summenzeile hinweg.
Die letzte Summenzelle ist in der Spalte I zu ermitteln oder für die Spalte 32 die letzte Summenzelle in
der Spalte V .
Sub SummenFormeln_setzen()
Dim lngRow As Long, lngLastRow As Long, lngStartRow As Long
Dim lngStartCol As Long, lngLastCol As Long
With ActiveSheet
lngStartRow = 5 'erste Datenzeile
lngStartCol = 9 'erste Datenspalte
lngLastRow = Application.Max(lngStartRow, .UsedRange.SpecialCells(xlCellTypeLastCell).Row)
lngLastCol = 19 'Application.Max(lngStartCol, .UsedRange.SpecialCells(xlCellTypeLastCell). _
_
_
Column)
lngStartRow = 4
For lngRow = lngStartRow To lngLastRow
If .Cells(lngRow, 9).Borders(xlEdgeTop).Weight = -4138 Then
With .Range(.Cells(lngRow, lngStartCol), .Cells(lngRow, lngLastCol))
.FormulaR1C1 = "=SUM(R[-" & lngRow - lngStartRow & "]C:R[-1]C)"
.Borders(xlEdgeBottom).LineStyle = xlDouble
End With
lngStartRow = lngRow + 1
Else
' .Cells(lngRow, 19).FormulaR1C1 = "=Sum(RC9:RC18)" '"=SUM(RC[-10]:RC[-1])"
.Cells(lngRow, 19).FormulaR1C1 = "=SUM(RC[-10]:RC[-1])"
If ActiveSheet.Range("U4") = "" Then
Else
.Cells(lngRow, 32).FormulaR1C1 = "=SUM(RC[-10]:RC[-1])"
End If
End If
Next
End With
End Sub
mfg kurt P