Sub
s_Summenformeln_schreiben()
Dim
strSuchwort
As
String
Dim
strCol
As
String
Dim
strAdr
As
String
Dim
lngCnt
As
Long
Dim
intCol
As
Integer
Dim
intZeile
As
Integer
Dim
i
As
Integer
Dim
intNaechsteSuchwortZeile
As
Integer
Dim
varNaechstesSuchwort
As
Variant
intCol = 12
strSuchwort =
"Summe"
strAdr = ActiveSheet.Cells(1, intCol).Address
lngCnt = InStr(2, strAdr,
"$"
) - 1
strCol = WorksheetFunction.Substitute(Left(strAdr, Len(strAdr) - (Len(strAdr) - lngCnt)),
"$"
,
""
)
intZeile = Cells(65536, intCol).
End
(xlUp).Row
Cells(1, intCol).Activate
For
i = 1
To
intZeile
If
Cells(i, intCol) = strSuchwort
Then
Columns(intCol).Find(What:=strSuchwort, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=
False
, SearchFormat:=
False
).Activate
intNaechsteSuchwortZeile = ActiveCell.Row
Cells(i, intCol).FormulaLocal =
"=Summe("
& strCol & i + 1 &
":"
& strCol & intNaechsteSuchwortZeile - 1 &
")"
End
If
Next
End
Sub